Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Create your custom stylesheets based on the taxonomy tid in
* $theme_dir/css/taxonomy/$tid.css
function THEME_preprocess_node(&$vars, $hook) {
if ($terms = taxonomy_node_get_terms($vars->['node'])) {
foreach ($terms as $term) {
$stylesheet = '/css/taxonomy/'. $term->tid .'.css';
if (file_exists(dirname(__FILE__) . $stylesheet)) {
drupal_add_css(path_to_theme() . $stylesheet);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment