Hi,
I love multimenu but I miss one important feature, when I hit a menu link then link should be turned to selected.
Yesterday I hacked multimenu so here's what the hack does:
When you click a mainmenu it highlights the mainmenu
When you click a submenu it highlights the correspondig mainmenu
When you browse your site in pages that aren´t linked directly in the menu it highlights the corresponding module menu.
If theres is no corresponding module menu than it highlights a default menu (Home for example, but you can change it)
To take a quick look just visit
http://www.luso-poemas.netSo here's what to do:
Go to modules/multiMenu/blocks/block.php
At the end find:
$block['contents'][] = $imenu;
} // Sublinks
} // Groups
}
return $block;
?>
And replace with this:
//start of hack by trabis for selected menus
$imenu['id'] = $myrow['id'];
$imenu['pid'] = $myrow['pid'];
$block['contents'][] = $imenu;
} // Sublinks
} // Groups
}
//get the currentpage
$query_string = $_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'';
$self = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$query_string;
//set a default page in case we don´t get matches
$default = XOOPS_URL."/index.php";
//get all the links that could fit into this pageplus the default link
$i = 0;
foreach ($block['contents'] as $menu){
$link = $menu['linkurl'];
$selected = eregi($menu['linkurl'], $self)? 1: 0;
$selected = ($menu['linkurl'] == $self) ? 1: $selected;
$selected = ($menu['linkurl'] == $default) ? 1: $selected;
$block['contents'][$i]['selected'] = $selected;
$i++;
}
//From those links get only the longer one
$i = 0;
$issub = 0;
foreach ($block['contents'] as $this_menu){
$other = 0;
foreach ($block['contents'] as $other_menu){
if($this_menu['selected']==1 && $other_menu['selected']==1){
if (strlen($other_menu['linkurl']) < strlen($this_menu['linkurl'])){
$block['contents'][$other]['selected'] = 0;
$issub = $this_menu['submenu'];
$subid = $this_menu['id'];
$subord = $i;
}
}
$other++;
}
$i++;
}
//if the longer link is in a sub menu than change selection to the parent menu
if ($issub == 1){
//get the parent menu
$sql = "SELECT id, pid, groups, link, submenu, title, target, imageurl, weight
FROM ".$xoopsDB->prefix('multimenu').$options[15]."
WHERE id=".$subid;
$result = $xoopsDB->queryF($sql);
$myrow = $xoopsDB->fetchArray($result);
$i = 0;
foreach ($block['contents'] as $mainmenu){
//changing selections
if ($mainmenu['id'] == $myrow['pid']){
$block['contents'][$i]['selected'] = 1;
$block['contents'][$subord]['selected'] = 0;
}
$i++;
}
}
//end of hack by trabis for selected menus
return $block;
?>
Ok, now you have an extra variable to use in your templates
<{if $imenu.selected}>add your class here<{/if}>
Here is an example for multimenu_dyn_horiz_css.html:
<div class="menuhcss">
<{assign var=ul_main value=0}>
<{assign var=ul_sec value=0}>
<{foreach item=imenu from=$block.contents}>
<{if $imenu.submenu == 0}>
<{if $ul_sec == 1}>ul><{assign var=ul_sec value=0}><{/if}>
<{if $ul_sec == 1}><{assign var=ul_sec value=0}><{/if}>
<{if $ul_main == 1}>
li>
ul>
<{assign var=ul_main value=0}>
<{/if}>
<{if $ul_main == 0}>
<{assign var=ul_main value=1}>
<{/if}>
<ul>
<li>
<a <{if $imenu.selected}>class="hide_selected"<{else}>class="hide"<{/if}><{if $imenu.linkurl}>href="<{$imenu.linkurl}>"<{/if}> title="<{$imenu.alt_title}>"><{$imenu.image}> <{$imenu.title}>a>
<{elseif $imenu.submenu == 1 OR $imenu.submenu == 2}>
<{if $ul_sec == 0}><ul><{assign var=ul_sec value=1}><{/if}>
<li><a <{if $imenu.linkurl}>href="<{$imenu.linkurl}>"<{/if}> title="<{$imenu.alt_title}>"><{$imenu.image}> <{$imenu.title}>a>li>
<{elseif $imenu.submenu == 3}>
<{if $ul_sec == 0}><ul><{assign var=ul_sec value=1}><{/if}>
<div><li><a class="note" <{if $imenu.linkurl}>href="<{$imenu.linkurl}>"<{/if}> title="<{$imenu.alt_title}>"><{$imenu.image}> <{$imenu.title}>a>li>div>
<{elseif $imenu.submenu == 4}>
<{if $ul_sec == 0}><ul><{assign var=ul_sec value=1}><{/if}>
<div><li><a class="cat" <{if $imenu.linkurl}>href="<{$imenu.linkurl}>"<{/if}> title="<{$imenu.alt_title}>"><{$imenu.image}> <{$imenu.title}>a>li>div>
<{/if}>
<{/foreach}>
<{if $ul_sec == 1}>ul><{/if}>
<{if $ul_main == 1 OR $ul_sec == 1}>
li>
ul>
<{/if}>
div>
You have to add the correspondig classes to the corresponding css, in my case I added class "selected" and "hide_selected".
In script/08/basic_dd.css:
.menuhcss ul li a.hide_selected, .menuhcss ul li a:visited.hide_selected, menuhcss ul li a.selected, .menuhcss ul li a:visited.selected{
background-image: url('http://www.luso-poemas.net/modules/multiMenu/templates/images/links_over.jpg');
background-repeat: repeat-x;
color: #027AD2;
height: 20px
padding: 0px;
}
In script/08/basic_dd_ie.css:
/* ignore the link used by 'other browsers' */
.menuhcss ul li a.hide, .menuhcss ul li a:visited.hide .menuhcss ul li a.hide_selected, .menuhcss ul li a:visited.hide_selected{
display:none;
}
That´s it!