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
Im using Drupal 6.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
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.