1

Im building a web page with multiple sub-portals, which should all have slightly different css styles. Is it possible to add a certain css file depending on the taxonomy of a node? With drupal_add_css maybe? Im using Drupal 6.

Thanks, Max

1

If you want to load certain CSS files based on taxonomy, maybe you could name your files according to taxonomy vocabularies. Just build the file name based on the vocabulary of a term.

$file = 'mymodule_taxonomy_' . $vocabulary . '.css';
drupal_add_css(drupal_get_path('module', 'mymodule') . '/' . $file);

If you have a node object you can use taxonomy_node_get_terms() to get the terms for a node and use this code to load a proper CSS file. Then, with a vocabulary named cars you can name a CSS file mymodule_taxonomy_cars.css. That file can be loaded according to a vocabulary.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.