You are here

function _dhtml_menu_index in DHTML Menu 6.3

Same name and namespace in other branches
  1. 8 dhtml_menu.theme.inc \_dhtml_menu_index()
  2. 6.4 dhtml_menu.theme.inc \_dhtml_menu_index()
  3. 7 dhtml_menu.theme.inc \_dhtml_menu_index()

Indexes the menu tree by mlid. This is needed to identify the items without relying on titles. This function is recursive.

Parameters

$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 _dhtml_menu_index()
_dhtml_menu_subtree in ./dhtml_menu.module
Traverses the menu tree and returns the sub-tree of the item indicated by the parameter.

File

./dhtml_menu.module, line 197
dhtml_menu.module Adds preprocessors to the menu theming functions that will add dynamic expansion to their menus.

Code

function _dhtml_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 += _dhtml_menu_index($item['below'], $ancestors, $item['link']['mlid']);
    }
  }
  return $index;
}