Same name and namespace in other branches
- 4.7.x includes/menu.inc \menu_tree()
- 5.x includes/menu.inc \menu_tree()
- 6.x includes/menu.inc \menu_tree()
- 7.x includes/menu.inc \menu_tree()
Returns a rendered menu tree.
Parameters
$pid: The parent id of the menu.
Related topics
File
- includes/
menu.inc, line 567 - 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) {
$output .= theme('menu_item', $mid, menu_in_active_trail($mid) || $menu['visible'][$mid]['type'] & MENU_EXPANDED ? theme('menu_tree', $mid) : '', count($menu['visible'][$mid]['children']) == 0);
}
}
return $output;
}