You are here

function _panopoly_widgets_menu_block_tree_expanded_max_depth_alter in Panopoly Widgets 7

Remove items from tree which are below the 'expanded_max_depth'.

1 call to _panopoly_widgets_menu_block_tree_expanded_max_depth_alter()
panopoly_widgets_menu_block_tree_alter in ./panopoly_widgets.module
Implements hook_menu_block_tree_alter().

File

./panopoly_widgets.module, line 593

Code

function _panopoly_widgets_menu_block_tree_expanded_max_depth_alter(&$tree, $config) {

  // Remove all items above the max depth.
  foreach ($tree as $name => &$item) {
    if (!$item['link']['in_active_trail'] && $item['link']['depth'] > $config['expanded_max_depth']) {
      unset($tree[$name]);
    }
    else {
      _panopoly_widgets_menu_block_tree_expanded_max_depth_alter($item['below'], $config);
    }
  }
}