Skip to content

Instantly share code, notes, and snippets.

@tamasd
Created November 23, 2012 12:21
Show Gist options
  • Save tamasd/4135387 to your computer and use it in GitHub Desktop.
Save tamasd/4135387 to your computer and use it in GitHub Desktop.
<?php
/**
* This function includes a css file based on the selected taxonomy terms.
* With this, the submitter can assign extra css for the site.
* @param $vid the vid of the taxonomy
*/
function _taxonomy_based_css_loader($vid){
$nid = null;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
}
else {
return;
}
$node = node_load($nid);
if (isset($node->taxonomy)) {
foreach ($node->taxonomy as $t) {
if ($t->vid == $vid) {
drupal_add_css(path_to_theme() . '/' . $t->name . '.css');
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment