I need to add a custom class to my html <body>
tag when certain elements are present in content (namely, either a featured image or image gallery, both of which are added to content using Entity Reference fields in the site's main content types).
Currently I'm accomplishing this using the Context module and a taxonomy vocabulary. (Condition: Taxonomy; Reaction: Theme HTML). The workflow for content managers looks like this:
- Add an image or gallery to a content item
- Don't forget to attach the appropriate taxonomy term so the page lays out correctly.
Oddly enough, forgetting step 2 is a rampant problem.
Any suggestions on methods for eliminating step 2? It seems like it ought to be possible to just test for the presence of a value in the appropriate fields and either automatically attach the taxonomy term, or skip the taxonomy term and trigger the theme HTML based on the data values themselves.
I should mention that the taxonomy vocabulary in question has NO purpose in my application other than applying the appropriate body class.
I'm open to using some other module to accomplish this. (Rules? Couldn't figure out how to make this work either).
(Drupal 7).