You are here

function _accordion_menu_index in Accordion Menu 6

Same name and namespace in other branches
  1. 7 includes/view.inc \_accordion_menu_index()

Returns the menu tree indexed by mlid.

This is needed to identify the items without relying on titles. This function is recursive.

Parameters

array $tree: A tree of menu items such as the return value of menu_tree_all_data()

Return value

An array associating mlid values with the internal keys of the menu tree.

1 call to _accordion_menu_index()
_accordion_menu_subtree in includes/view.inc
Returns the tree of items below a menu item.

File

includes/view.inc, line 271
Provides view routines.

Code

function _accordion_menu_index($tree, $ancestors = array(), $parent = NULL) {
  $index = array();
  if ($parent) {
    $ancestors[] = $parent;
  }
  foreach ($tree as $key => $item) {
    $index[$item['link']['mlid']] = array(
      'key' => $key,
      'parents' => $ancestors,
    );
    if (!empty($item['below'])) {
      $index += _accordion_menu_index($item['below'], $ancestors, $item['link']['mlid']);
    }
  }
  return $index;
}