You are here

function menu_tree_trim_active_path in Menu Block 7.2

Same name and namespace in other branches
  1. 6.2 menu_block.module \menu_tree_trim_active_path()
  2. 7.3 menu_block.module \menu_tree_trim_active_path()

Trim everything but the active trail in the tree.

Parameters

array $tree: The menu tree to trim.

1 call to menu_tree_trim_active_path()
menu_tree_block_data in ./menu_block.module
Gets the data structure representing a menu tree for the given configuration.

File

./menu_block.module, line 659
Provides configurable blocks of menu items.

Code

function 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.
      menu_tree_trim_active_path($tree[$key]['below']);
    }
    else {

      // Trim anything not expanded or along the active trail.
      $tree[$key]['below'] = FALSE;
    }
  }
}