function responsive_menu_tree_block_data in Responsive and off-canvas menu 7.3
Same name and namespace in other branches
- 7 includes/responsive_menu.menu.inc \responsive_menu_tree_block_data()
- 7.2 includes/responsive_menu.menu.inc \responsive_menu_tree_block_data()
Gets the data structure representing a menu tree for the given configuration.
Parameters
$config: See the $config param of menu_tree_build().
2 calls to responsive_menu_tree_block_data()
- responsive_menu_block_view in ./
responsive_menu.module - Implements hook_block_view().
- responsive_menu_page_build in ./
responsive_menu.module - Implements hook_page_build().
File
- includes/
responsive_menu.menu.inc, line 144 - Functions which process the menu.
Code
function responsive_menu_tree_block_data($menu_name, $max_depth = NULL) {
$tree = menu_tree_all_data($menu_name, NULL, $max_depth);
// And add the active trail data back to the full tree.
$menu_item = current($tree);
$tree_with_trail = menu_tree_page_data($menu_item['link']['menu_name'], $max_depth);
// 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'] && isset($subtree_pointer[$key])) {
// 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]);
}
}
}
// Allow alteration of the tree and config before we begin operations on it.
drupal_alter('responsive_menu_tree', $tree, $menu_name);
// Localize the tree.
if (module_exists('i18n_menu')) {
$tree = i18n_menu_localize_tree($tree);
}
// Trim the branches that extend beyond the specified depth.
responsive_menu_tree_depth_trim($tree, $max_depth);
return $tree;
}