Xuups
Get an account!     Login

Utilities

Main menu

Who's Online

16 user(s) are online (1 user(s) are browsing Hacks and Tips)

Members: 0
Guests: 16

more...

Get Xoops

Support Xuups Project

Modules :  Highlighting current module on mainMenu
Tags: hack   mainmenu   highlight  
 
This tip is about highlighting the mainMenu Links accordingly to the module that you are browsing.

It requires hacking to system files.

Edit system/blocks/system_blocks and use this:
function b_system_main_show()
{
    global 
$xoopsUser,$xoopsModule;
    
$block = array();
    
$block['lang_home'] = _MB_SYSTEM_HOME;
    
$block['lang_close'] = _CLOSE;
    
$module_handler =& xoops_gethandler('module');
    
$criteria = new CriteriaCompo(new Criteria('hasmain'1));
    
$criteria->add(new Criteria('isactive'1));
    
$criteria->add(new Criteria('weight'0'>'));
    
$modules $module_handler->getObjects($criteriatrue);
    
$moduleperm_handler =& xoops_gethandler('groupperm');
    
$groups is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
    
$read_allowed $moduleperm_handler->getItemIds('module_read'$groups);
    foreach (
array_keys($modules) as $i) {
        if (
in_array($i$read_allowed)) {
            
$block['modules'][$i]['name'] = $modules[$i]->getVar('name');
            
$block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname');
            
$sublinks $modules[$i]->subLink();
            
// trabis hack
            
if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
                
$block['modules'][$i]['highlight'] = true;
                
$block['nothome'] = true;
            }
            
//end of trabis hack
            
if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
                foreach(
$sublinks as $sublink){
                    
$block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
                }
            } else {
                
$block['modules'][$i]['sublinks'] = array();
            }
        }
    }
    return 
$block;
}


Then edit system/templates/blocks/system_block_mainmenu.html and use this:

<table cellspacing="0">
  <
tr>
    <
td id="mainmenu">
      <
class="menuTop" href="<{$xoops_url}>/" <{if !$block.nothome}>style="color:red;"<{/if}>><{$block.lang_home}></a>
      <!-- 
start module menu loop -->
      <{foreach 
item=module from=$block.modules}>
      <
class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/" <{if $module.highlight}>style="color:red;"<{/if}>><{$module.name}></a>
        <{foreach 
item=sublink from=$module.sublinks}>
          <
class="menuSub" href="<{$sublink.url}>"><{$sublink.name}></a>
        <{/foreach}>
      <{/foreach}>
      <!-- 
end module menu loop -->
    </
td>
  </
tr>
</
table>


I have chosen the color "red" in this example but you can style it the way you want.

Enjoy

PS: Codes are based on xoops 2.3.2 system module


TDM

Author
trabis
Author trabis
News by the same authorMore stories
Author rssAuthor rss
StatisticsStatistics
 
Story
Date 2008/12/15 19:23:02
Views 3740
Favorites 0
Send this Story to a FriendSend
Printer Friendly PagePrint
Create a PDF from the articleCreate a pdf
 
Bookmarks
         
         
         
         
         
     
Recents
How to sucessfuly add scripts in your Xoops Themes
Query timers on debug for xoops 2.3
Highlighting current module on mainMenu
Main menu hack - on click submenus
Preventing empty blocks to display
Random
Query timers on debug for xoops 2.3
Main menu hack - on click submenus
Preventing empty blocks to display
Adding an horizontal multiMenu to Xoops
Hacking Multimenu - Selected menus
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
Tzvook
Posted: 2008/12/22 6:52  Updated: 2008/12/22 6:52
Just popping in
Joined: 2008/12/6
From:
Posts: 2
 Re: Highlighting current module on mainMenu
Hi Trabis
This one will be very useful for using in the "theme" too
( a switch for 'adding / removing' theme elements acording to the module) ...
Waqar
Posted: 2009/10/16 13:24  Updated: 2009/10/16 13:33
Just popping in
Joined: 2009/8/30
From:
Posts: 5
 Re: Highlighting current module on mainMenu
How can i keep current tab highlighted using mytabs module. i have created a tabbed menu using mytabs module but it is not keeping the selected link highlighted
 

Login

Username:

Password:

Remember me



Lost Password?

Register now!

Ajax Search


Advanced Search

Sub menu

Last comments