Created
November 12, 2012 13:02
-
-
Save driesdelaey/4059286 to your computer and use it in GitHub Desktop.
set taxonomy as class on node detail / set parent taxonomy term on term detail
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
function community_preprocess_html(&$vars) { | |
// set thema_[tid] class when on node detail | |
if(isset($vars['page']['content']['system_main']['nodes'])) { | |
$node = reset($vars['page']['content']['system_main']['nodes']); | |
if(isset($node['field_thema']['#items'][0]['tid'])){ | |
$vars['classes_array'][] = 'thema_' . $node['field_thema']['#items'][0]['tid']; | |
} | |
} | |
// set parent level thema_[tid] class on taxonomy detail | |
if(arg(0) == 'taxonomy' && arg(1) == 'term') { | |
$tid = (int)arg(2); | |
$the_parents = taxonomy_get_parents($tid); | |
foreach ($the_parents as $the_parent) { | |
//kpr($the_parent); | |
$vars['classes_array'][] = 'thema_' . $the_parent->tid; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment