/ Published in: PHP
Expand |
Embed | Plain Text
... $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; }
You need to login to post a comment.
