function menu_tree_output in Drupal 6
Same name and namespace in other branches
- 7 includes/menu.inc \menu_tree_output()
Returns a rendered menu tree.
Parameters
$tree: A data structure representing the tree as returned from menu_tree_data.
Return value
The rendered HTML of that data structure.
Related topics
3 calls to menu_tree_output()
- book_block in modules/
book/ book.module - Implementation of hook_block().
- book_children in modules/
book/ book.module - Format the menu links for the child pages of the current page.
- menu_tree in includes/
menu.inc - Render a menu tree based on the current path.
File
- includes/
menu.inc, line 739 - API for the Drupal menu system.
Code
function menu_tree_output($tree) {
$output = '';
$items = array();
// Pull out just the menu items we are going to render so that we
// get an accurate count for the first/last classes.
foreach ($tree as $data) {
if (!$data['link']['hidden']) {
$items[] = $data;
}
}
$num_items = count($items);
foreach ($items as $i => $data) {
$extra_class = array();
if ($i == 0) {
$extra_class[] = 'first';
}
if ($i == $num_items - 1) {
$extra_class[] = 'last';
}
$extra_class = implode(' ', $extra_class);
$link = theme('menu_item_link', $data['link']);
if ($data['below']) {
$output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
}
else {
$output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
}
}
return $output ? theme('menu_tree', $output) : '';
}