Skip to content

Instantly share code, notes, and snippets.

@malclocke
Created June 2, 2010 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malclocke/421827 to your computer and use it in GitHub Desktop.
Save malclocke/421827 to your computer and use it in GitHub Desktop.
<?php
/**
* 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