Do souboru template.php přidejte:
function menu_tree_full($menu_name = 'navigation') {
$tree = array();
if (!isset($menu_output[$menu_name])) {
$tree = menu_find_active_trail(menu_tree_all_data($menu_name));
}
return $tree;
}
/**
* Wrapper function
*/
function menu_find_active_trail(&$menu_tree) {
$item = menu_get_item();
_menu_find_active_trail($menu_tree, $item);
return $menu_tree;
}
/**
* Recursive function to find the active menu and the active trail in the given tree.
*/
function _menu_find_active_trail(&$menu_tree, $item) {
foreach($menu_tree as &$menu_item) {
$link = &$menu_item['link'];
if ($link['href']==$item['href']) { // Found the exact location in the tree
$link['active'] = TRUE;
$link['in_active_trail'] = TRUE;
return true;
} else {
if ($menu_item['below']) {
$result = _menu_find_active_trail($menu_item['below'], $item);
$link['in_active_trail'] = $result;
if ($result)
{
$link['active'] = TRUE;
$link['in_active_trail'] = TRUE;
return true;
}
}
}
}
return false;
}
A v souboru theme/theme.inc upravte okolo řádku 102-105
// primary links markup
if (theme_get_setting('menu_type') == 2) { // use mega menu
$vars['mainmenu'] = theme('mega_menu', array('menu' => menu_tree_all_data(theme_get_setting('menu_element'))));
}
na
// primary links markup
if (theme_get_setting('menu_type') == 2) { // use mega menu
$vars['mainmenu'] = theme('mega_menu', array('menu' => menu_tree_full(theme_get_setting('menu_element'))));
}
Konečně v témže souboru okolo řádku 129 přidejte
if ($value['link']['in_active_trail']) {
$options['attributes']['class'] = array('active');
}
Více informací najdete zde nebo v denním tisku.
Žádné komentáře:
Okomentovat