function _accordion_menu_subtree in Accordion Menu 7
Same name and namespace in other branches
- 6 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 a render array of the accordion menu tree.
File
- includes/
view.inc, line 277 - Provides view routines.
Code
function _accordion_menu_subtree(array $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 isset($tree[$key]) ? $tree[$key]['below'] : array();
}