function theme_dhtml_menu_item in DHTML Menu 6
Same name and namespace in other branches
- 5 dhtml_menu.module \theme_dhtml_menu_item()
- 6.2 dhtml_menu.theme.inc \theme_dhtml_menu_item()
Theme each menu item, adding important CSS data
1 theme call to theme_dhtml_menu_item()
- theme_dhtml_menu_tree in ./
dhtml_menu.inc - Theme each menu, adding important CSS data
File
- ./
dhtml_menu.inc, line 40 - dhtml_menu.inc Allow click expansion of the menu tree via javascript, with graceful degradation.
Code
function theme_dhtml_menu_item($item, $id) {
static $expanded = NULL;
if (!is_array($expanded)) {
if (!isset($_COOKIE['dhtml_menu'])) {
$_COOKIE['dhtml_menu'] = '';
}
$expanded = explode(',', $_COOKIE['dhtml_menu']);
}
// Unset hidden sub-items. This avoids items with empty, all-hidden sub-menus.
if (!empty($item['below'])) {
foreach ($item['below'] as $index => $leaf) {
if ($leaf['link']['hidden']) {
unset($item['below'][$index]);
}
}
}
// Check if the menu item has a submenu
// If no, create a normal menu item
// If yes, create the submenu too
if (empty($item['below'])) {
return ' <li class="leaf" id="menu-leaf' . $id . '">' . theme('menu_item_link', $item['link']) . "</li>\n";
}
else {
$type = isset($item['link']['type']) ? $item['link']['type'] : NULL;
if ($item['link']['in_active_trail'] or $item['link']['expanded'] or in_array("sub{$id}", $expanded)) {
$state = 'expanded';
$display = '';
}
else {
$state = 'collapsed';
$display = ' style="display: none;"';
}
return "<li class=\"menutitle {$state}\" id=\"menu-sub{$id}\">" . theme('menu_item_link', $item['link']) . "<div class=\"submenu\" id=\"sub{$id}\"{$display}>" . theme('dhtml_menu_tree', $item['below'], $item['link'], $id) . '</div>' . '</li>';
}
}