Skip to content

Instantly share code, notes, and snippets.

@driesdelaey
Created November 12, 2012 13:02
Show Gist options
  • Save driesdelaey/4059286 to your computer and use it in GitHub Desktop.
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
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