function dhtml_menu_theme_menu_item in DHTML Menu 6.3
Same name and namespace in other branches
- 8 dhtml_menu.theme.inc \dhtml_menu_theme_menu_item()
- 6.4 dhtml_menu.theme.inc \dhtml_menu_theme_menu_item()
Preprocessor for menu_item. Checks whether the current item has children that were not rendered, and loads and renders them.
1 string reference to 'dhtml_menu_theme_menu_item'
- dhtml_menu_update_6003 in ./
dhtml_menu.install - #6003: 6.x-3.4 upgrade. Remove two obsolete variables and rebuild all themes.
File
- ./
dhtml_menu.module, line 88 - dhtml_menu.module Adds preprocessors to the menu theming functions that will add dynamic expansion to their menus.
Code
function dhtml_menu_theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
global $theme;
static $cookie, $settings, $function;
if (!isset($cookie)) {
$settings = variable_get('dhtml_menu_effects', unserialize(DHTML_MENU_DEFAULT));
// Do not use this feature when keeping only one menu open at a time - the active path will always be open.
$cookie = !empty($_COOKIE['dhtml_menu']) && empty($settings['siblings']) ? explode(',', $_COOKIE['dhtml_menu']) : array();
// Cascade up to the original theming function.
$registry = variable_get('dhtml_menu_theme', array());
$function = isset($registry[$theme]) ? $registry[$theme]['menu_item'] : 'theme_menu_item';
}
/* When theme('menu_item') is called, the menu tree below it has been
* rendered already. Since we are done on this recursion level,
* one element must be popped off the stack.
*/
$item = _dhtml_menu_stack();
// If this item should not have DHTML, then return to the "parent" function.
if (!empty($item['dhtml_disabled'])) {
$extra_class .= ' no-dhtml ';
return $function($link, $has_children, $menu, $in_active_trail, $extra_class);
}
// Otherwise, add a class to identify this element for JS.
$extra_class .= ' dhtml-menu ';
// If there are children, but they were not loaded...
if ($has_children && !$menu) {
// Load the tree below the current position.
$tree = _dhtml_menu_subtree($item);
// Render it...
$menu = menu_tree_output($tree);
if (!$menu) {
$has_children = FALSE;
}
// Sanitize tree. If we found no children, the item has none.
}
// If the current item can expand, and is neither saved as open nor in the active trail, close it.
if ($menu && !($in_active_trail || in_array(substr($item['options']['attributes']['id'], 5), $cookie))) {
$extra_class .= ' collapsed start-collapsed ';
}
return $function($link, $has_children, $menu, $in_active_trail, $extra_class);
}