function ultimenu_tree_add_active_path in Ultimenu 7
Add the active trail indicators into the tree.
The data returned by menu_tree_page_data() has link['in_active_trail'] set to TRUE for each menu item in the active trail. The data returned from menu_tree_all_data() does not contain the active trail indicators. This is a helper function that adds it back in.
Function copy of menu_tree_add_active_path() from menu_block 7.x-2.3.
Parameters
$tree: array The menu tree.
Return value
void
1 call to ultimenu_tree_add_active_path()
- ultimenu_block_view in ./
ultimenu.module - Implements hook_block_view().
File
- includes/
ultimenu.utilities.inc, line 408 - Misc functions that hardly change.
Code
function ultimenu_tree_add_active_path(&$tree) {
// Grab any menu item to find the menu_name for this tree.
$menu_item = current($tree);
$tree_with_trail = menu_tree_page_data($menu_item['link']['menu_name']);
// To traverse the original tree down the active trail, we use a pointer.
$subtree_pointer =& $tree;
// Find each key in the active trail.
while ($tree_with_trail) {
foreach ($tree_with_trail as $key => &$value) {
if ($tree_with_trail[$key]['link']['in_active_trail']) {
// Set the active trail info in the original tree.
$subtree_pointer[$key]['link']['in_active_trail'] = TRUE;
// Continue in the subtree, if it exists.
$tree_with_trail =& $tree_with_trail[$key]['below'];
$subtree_pointer =& $subtree_pointer[$key]['below'];
break;
}
else {
unset($tree_with_trail[$key]);
}
}
}
}