function _dhtml_menu_subtree in DHTML Menu 6.4
Same name and namespace in other branches
- 8 dhtml_menu.theme.inc \_dhtml_menu_subtree()
- 6.3 dhtml_menu.module \_dhtml_menu_subtree()
- 7 dhtml_menu.theme.inc \_dhtml_menu_subtree()
Traverses the menu tree and returns the sub-tree of the item indicated by the parameter.
Parameters
$item: A menu item link that must contain the keys "mlid" and "menu_name".
Return value
The tree below the menu item, or an empty array.
1 call to _dhtml_menu_subtree()
- dhtml_menu_theme_menu_item in ./
dhtml_menu.theme.inc - Preprocessor for menu_item. Checks whether the current item has children that were not rendered, and loads and renders them.
File
- ./
dhtml_menu.theme.inc, line 138 - dhtml_menu.theme.inc All functions related to generating the menu markup.
Code
function _dhtml_menu_subtree($item) {
static $index = array();
static $indexed = array();
// This looks expensive, but menu_tree_all_data uses static caching.
$tree = menu_tree_all_data($item['menu_name']);
// Index the menu tree to find ancestor paths for each item.
if (!isset($indexed[$item['menu_name']])) {
$index += _dhtml_menu_index($tree);
$indexed[$item['menu_name']] = TRUE;
}
// If the menu tree does not contain this item, stop.
if (!isset($index[$item['mlid']])) {
return array();
}
// Traverse the tree using the ancestor path.
foreach ($index[$item['mlid']]['parents'] as $mlid) {
$key = $index[$mlid]['key'];
if (isset($tree[$key])) {
$tree = $tree[$key]['below'];
}
else {
return array();
}
}
// Go one level further to go below the current item.
$key = $index[$item['mlid']]['key'];
return isset($tree[$key]) ? $tree[$key]['below'] : array();
}