/ Published in: PHP
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/)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
... $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; }