将';活动';类添加到';菜单树所有数据';结果
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将';活动';类添加到';菜单树所有数据';结果相关的知识,希望对你有一定的参考价值。
Via: [http://www.touchdesk.nl/2009/04/full-menu-tree-with-active-trail-in-drupal-6/](http://www.touchdesk.nl/2009/04/full-menu-tree-with-active-trail-in-drupal-6/)
... $data = menu_find_active_trail(menu_tree_all_data(...)); ... /** * Wrapper function */ function menu_find_active_trail(&$menu_tree) { $item = menu_get_item(); _menu_find_active_trail($menu_tree, $item); return $menu_tree; } /** * Recursive function to find the active menu and the active trail in the given tree. */ function _menu_find_active_trail(&$menu_tree, $item) { $level_is_expanded = FALSE; foreach($menu_tree as &$menu_item) { $link = &$menu_item['link']; if ($link['href']==$item['href']) { // Found the exact location in the tree $link['active'] = TRUE; $link['in_active_trail'] = TRUE; return true; } else { if ($link['has_children']) { $result = _menu_find_active_trail($menu_item['below'], $item); $link['in_active_trail'] = $result; if ($result) $level_is_expanded = TRUE; } } } return $level_is_expanded; }
以上是关于将';活动';类添加到';菜单树所有数据';结果的主要内容,如果未能解决你的问题,请参考以下文章