1
chapi
Tutorial: Highlight the active module in your mainmenu
  • 2004/1/26 17:08

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


You want to highlight the currently viewed module in your mainmenu? Here is how to do this ...

1.) Edit the following file:
/modules/system/blocks/system_blocks.php

Search for this function (about line 106) in this file:
function b_system_main_show()

insert this 2 lines before the foreach

$mod $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');


and this line after if (in_array($i, $read_allowed)) {

$block['modules'][$i]['current'] = $dirname;



2.) Define a new style for an active Mainmenu link in your
themes styles.css

td#mainmenu a.menuMainActive {
    /* your individual settings */
}



3.) Edit the Template for the Mainmenu Block

<table cellspacing="0">
  <
tr>
    <
td id="mainmenu">
      <
class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}>a>
      
      <{foreach 
item=module from=$block.modules}>
<{if 
$module.current == $module.directory}>
  <
class="menuMainActive" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}>a>
<{else}>
  <
class="menuMain" href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}>a>
<{/if}>
        <{foreach 
item=sublink from=$module.sublinks}>
          <
class="menuSub" href="<{$sublink.url}>"><{$sublink.name}>a>
        <{/foreach}>
      <{/foreach}>
      
    td>
  tr>
table>


Now the currently viewed module should be displayed with your custom css style in your main menu.

2
Stewdio
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/1/26 18:29

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Handy little tip, thanks for sharing

3
carnuke
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/1/26 21:46

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


Chapi, Thank-you for sharing this useful snippet. I look forward to trying it out

Richard

4
Vargr
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/2/6 15:22

  • Vargr

  • Not too shy to talk

  • Posts: 130

  • Since: 2003/6/19


HAHA!

Great forum this is!

I just got the idea to do exactly this the other day and was trying to figure out how to do it.

Was just about to ask the question here, but decided to search for it first.

And lo and behold - there it was!

I am looking forward to try it out tonight!

Thank you very much.


[Later edition]

Works like a charm!

Now, if only I could learn to read the easy-to-follow instructions properly I could have saved some time. But making those mistakes gave me a little better understanding of the various parts of Xoops.

Now I will see if I can make the HOME module highlight as well.

Thanks again.

5
Vargr
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/2/7 23:33

  • Vargr

  • Not too shy to talk

  • Posts: 130

  • Since: 2003/6/19


After having tried your trick with the main menu (and loving it), I wonder if the same could be done woth the user menu?

I had a look at it but the code for that part of the system_blocks.php is different than for the main menu and I can't figure out how it should be done. Not that good at PHP...

Can you - or anyone else - give me a few pointers?

Thank you in advance.

6
Brad
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/2/9 16:18

  • Brad

  • Not too shy to talk

  • Posts: 150

  • Since: 2003/12/4


Quote:
Now I will see if I can make the HOME module highlight as well.

Were you ever able to do this?

7
Vargr
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/2/25 19:06

  • Vargr

  • Not too shy to talk

  • Posts: 130

  • Since: 2003/6/19


No.

Suddenly real life crept up on me and I haven't had time to play with it. I believe it should be possible, though.

Highlighting the other modules works very well.

Sorry I can not help you more. Perhaps some time in the future

8
Brad
Re: Tutorial: Highlight the active module in your mainmenu
  • 2004/2/26 15:12

  • Brad

  • Not too shy to talk

  • Posts: 150

  • Since: 2003/12/4


Thanks for your response. Darn real life, always muddling up the best of our plans.

9
risto
Re: Tutorial: Highlight the active module in your mainmenu
  • 2005/3/3 9:06

  • risto

  • Not too shy to talk

  • Posts: 159

  • Since: 2003/4/16


I can't get it to work in 2.0.9.2

Any ideas?

10
DocuAnt
Re: Tutorial: Highlight the active module in your mainmenu
  • 2005/3/24 21:50

  • DocuAnt

  • Just popping in

  • Posts: 6

  • Since: 2005/3/22


Hi risto

After step 3 you have to update the system module.
Then it works also on 2.0.9.2 installations.

Login

Who's Online

292 user(s) are online (185 user(s) are browsing Support Forums)


Members: 0


Guests: 292


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits