4.6.x menu.inc menu_tree($pid = 1)
4.7.x menu.inc menu_tree($pid = 1)
5.x menu.inc menu_tree($pid = 1)
6.x menu.inc menu_tree($menu_name = 'navigation')
7.x menu.inc menu_tree($menu_name)

Returns a rendered menu tree.

Parameters

$pid: The parent id of the menu.

Related topics

1 call to menu_tree()
theme_menu_tree in includes/menu.inc
Generate the HTML for a menu tree.
2 string references to 'menu_tree'
menu_block in modules/menu/menu.module
Implementation of hook_block().
user_block in modules/user/user.module
Implementation of hook_block().

File

includes/menu.inc, line 658
API for the Drupal menu system.

Code

function menu_tree($pid = 1) {
  $menu = menu_get_menu();
  $output = '';

  if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
    foreach ($menu['visible'][$pid]['children'] as $mid) {
      $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL;
      $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL;
      $output .= theme('menu_item', $mid, menu_in_active_trail($mid) || ($type & MENU_EXPANDED) ? theme('menu_tree', $mid) : '', count($children) == 0);
    }
  }

  return $output;
}