1 system.menu.inc system_menu_tree_trim_active_path(array &$tree)

Trim everything but the active trail in the tree.

Parameters

array $tree: The menu tree to trim.

File

core/modules/system/system.menu.inc, line 424
Menu block configuration form and display.

Code

function system_menu_tree_trim_active_path(array &$tree) {
  foreach ($tree as $key => &$value) {
    if (($tree[$key]['link']['in_active_trail'] || $tree[$key]['link']['expanded']) && $tree[$key]['below']) {
      // Continue in the subtree, if it exists.
      system_menu_tree_trim_active_path($tree[$key]['below']);
    }
    else {
      // Trim anything not expanded or along the active trail.
      $tree[$key]['below'] = FALSE;
    }
  }
}