I would like to add class to the HTML element based on taxonomy. Is it possible to do it from inside template.tpl.php or do I need to create needed templates manually? If so, how will my theme know which template it should pick? Thank you
Tell me more
×
Drupal Answers is a question and answer site for
Drupal developers and administrators. It's 100% free, no registration required.
You can do this by adding a preprocess function to your template file that detects if the current node has terms associated with it and if so, populates a variable for the page.tpl.php according to your logic, ex:
Then, in your page.tpl.php file in your theme, you just need to add the above variable where you want it in the HTML tag.
If the variable is empty, no class will be output. |
|||
|