function _accordion_menu_subtree in Accordion Menu 6
Same name and namespace in other branches
- 7 includes/view.inc \_accordion_menu_subtree()
Returns the tree of items below a menu item.
Parameters
array $item: A menu item whose children are to be found.
Return value
array An associative array of the items below the menu item.
1 call to _accordion_menu_subtree()
- accordion_menu_output in includes/
view.inc - Returns rendered accordion menu tree.
File
- includes/
view.inc, line 235 - Provides view routines.
Code
function _accordion_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 += _accordion_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 !empty($tree[$key]['below']) ? $tree[$key]['below'] : array();
}