function simplemenu_tree_output in SimpleMenu 6
Same name and namespace in other branches
- 6.2 simplemenu.module \simplemenu_tree_output()
\brief Duplicate of menu_tree_output() to handle the block list.
This function handles the block list properly by skipping the theme() function usage whenever the user is in the list of blocks page. This means the possible theming of simplemenu will "break" on that page.
\param[in] $tree The menu tree to be displayed. \param[in] $id The identifier to add to the ul tag.
\return The menu tree in the form of a \<ul> list.
1 call to simplemenu_tree_output()
- simplemenu_get_menu in ./
simplemenu.module - Render an HTML list of links for a given menu.
File
- ./
simplemenu.module, line 462 - Creates a simplemenu.
Code
function simplemenu_tree_output($tree, $id) {
static $cnt = 0;
$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;
}
}
$inactive_parents = module_exists('simplemenu_inactive_parents');
$last_item = count($items) - 1;
foreach ($items as $i => $data) {
if ($data['link']['title'] == '-') {
$link = '<span class="simplemenu-separator"></span>';
}
elseif ($inactive_parents && !empty($data['link']['has_children'])) {
++$cnt;
$link = '<a name="menu-id-' . $cnt . '">' . $data['link']['title'] . '</a>';
}
elseif (empty($data['link']['localized_options'])) {
$link = l($data['link']['title'], $data['link']['href']);
}
else {
$link = l($data['link']['title'], $data['link']['href'], $data['link']['localized_options']);
}
$menu = $data['below'] ? simplemenu_tree_output($data['below'], $data['link']['mlid']) : '';
if ($menu) {
$class = 'expanded';
}
elseif ($data['link']['has_children']) {
$class = 'collapsed';
}
else {
$class = 'leaf';
}
if ($i == 0) {
$class .= ' first';
}
if ($i == $last_item) {
$class .= ' last';
}
if ($data['link']['in_active_trail']) {
$class .= ' active-trail';
}
$output .= '<li class="' . $class . '" id="simplemenu-li-' . $data['link']['mlid'] . '">' . $link . $menu . "</li>\n";
}
if ($id) {
$id = ' id="simplemenu-ul-' . $id . '"';
}
return $output ? '<ul class="menu"' . $id . '>' . $output . '</ul>' : '';
}