function _dhtml_menu_subtree in DHTML Menu 6.3
Same name and namespace in other branches
- 8 dhtml_menu.theme.inc \_dhtml_menu_subtree()
- 6.4 dhtml_menu.theme.inc \_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: An menu item whose children should be found.
Return value
The items below the passed menu item.
1 call to _dhtml_menu_subtree()
- dhtml_menu_theme_menu_item in ./
dhtml_menu.module - Preprocessor for menu_item. Checks whether the current item has children that were not rendered, and loads and renders them.
File
- ./
dhtml_menu.module, line 163 - dhtml_menu.module Adds preprocessors to the menu theming functions that will add dynamic expansion to their menus.
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 tree to find the path to this item.
if (!isset($indexed[$item['menu_name']])) {
$index += _dhtml_menu_index($tree);
$indexed[$item['menu_name']] = TRUE;
}
// Traverse the tree.
foreach ($index[$item['mlid']]['parents'] as $mlid) {
$key = $index[$mlid]['key'];
if (!isset($tree[$key])) {
return array();
}
$tree = $tree[$key]['below'];
}
$key = $index[$item['mlid']]['key'];
return isset($tree[$key]['below']) && is_array($tree[$key]['below']) ? $tree[$key]['below'] : array();
}