Created
November 23, 2012 12:21
-
-
Save tamasd/4135387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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