/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*Change menu*/ /** * Override menu links output * NOTE: change function name to match theme name **/ /*CHANGED Created body id based on section vocabulary */ //TODO Add is_front function _phptemplate_variables($hook, $vars) { switch ($hook) { case 'page': /*need to check for taxonomy or admin system flips out*/ /* Get the taxonomy info from the current node while in the page */ $node_taxonomy_object = $vars['node']->taxonomy; if ($node_taxonomy_object) { foreach ($node_taxonomy_object as $tax_object) { $vid = $tax_object->vid; switch($tax_object->vid){ case 14: #works for primary navigation like mysite.com/about/ if (!arg(3) && !arg(2) ) { $id = $vars['node']->nid; $terms = taxonomy_node_get_terms_by_vocabulary($id, $vid); foreach ($terms as $term) { $termID = $term->tid; $body_id = $term->name; } $parentCheck = taxonomy_get_parents($termID); if ($parentCheck == NULL){ $vars['body_class'] = 'noselect'; } } #Works for second-level navigation like mysite.com/about/mission/ if (!arg(3)) { $id = $vars['node']->nid; $terms = taxonomy_node_get_terms_by_vocabulary($id, $vid); foreach ($terms as $term) { $termID = $term->tid; $body_class = $term->name; } //get parents $parents = taxonomy_get_parents($termID); foreach ($parents as $parent){ $body_id=$parent->name; } #account for having no parents, really redundant, needs to be shortened. $parentCheck = taxonomy_get_parents($termID); if ($parentCheck == NULL){ $vars['body_class'] = 'noselect'; } } # No third-level navigation on static pages break; #designed for non-static pages, pages not set as "Pages" default: #works for primary navigation like mysite.com/about/ $vocab = taxonomy_get_vocabulary($vid); $body_id = $vocab->name; if (!arg(3) && !arg(2)) { $vars['body_class'] = 'noselect'; } # Works for second-level navigation like mysite.com/about/mission/ if (!arg(3)) { $id = $vars['node']->nid; $terms = taxonomy_node_get_terms_by_vocabulary($id, $vid); foreach ($terms as $term) { $termID = $term->tid; $body_class = $term->name; } } # Works for third-level navigation like mysite.com/about/mission/article.html if (arg(3)) { $id = $vars['node']->nid; $terms = taxonomy_node_get_terms_by_vocabularies($id, $vid); foreach ($terms as $term) { $termID = $term->tid; $body_class = $term->name; } //echo "Body Class =" . $body_class; } } } } return $vars; } }