基于drupal分类法的菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于drupal分类法的菜单相关的知识,希望对你有一定的参考价值。
/*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 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; } }
以上是关于基于drupal分类法的菜单的主要内容,如果未能解决你的问题,请参考以下文章