Elxis CMS Forum

Extensions => Templates => Topic started by: LT-user on March 23, 2008, 11:54:51

Title: How to set the current state for menu ?
Post by: LT-user on March 23, 2008, 11:54:51
How to set the current state for menu ? I want the link in the menu for the current page to appear differently e.g. bold. 

Anyone a solution?

Title: Re: How to set the current state for menu ?
Post by: CREATIVE Options on March 23, 2008, 12:31:21
From your css.
What template are you use?
Title: Re: How to set the current state for menu ?
Post by: LT-user on March 23, 2008, 12:36:31
I creating my own template.  8)  and I want to set current menu items. I will try...something  ;D
Title: Re: How to set the current state for menu ?
Post by: Farhad Sakhaei on March 23, 2008, 13:32:38
Use:
a#active_menu  or
.mainlevel#active_menu or
a.mainlevel#active_menu

in your .css file of template
Title: Re: How to set the current state for menu ?
Post by: LT-user on March 23, 2008, 18:18:20
Thanx it's working... ;) but...

Now, when I click a menu item a page appears with a second menu. I want the item in the first menu to stay active and the first item in the second menu should also be active.  ::)

Title: Re: How to set the current state for menu ?
Post by: Ivan Trebješanin on March 23, 2008, 22:11:15
Can you give us a link? I can't really understand what you want to do... :P
Title: Re: How to set the current state for menu ?
Post by: LT-user on March 25, 2008, 11:20:44
I have a main menu button which has 2 sub menu buttons. Everything I want to do is the main menu schould stay active if the sub menu-item is activated.

Home
About us                                ( active mainmenu item)
|____About Us Item 1
|____About Us Item 2             (active submenu item)
Another Menu

Etc.

When a user selects one of these submenu items, I want the active submenu AND mainmenu items to be hilighted using active_menu

thanks for the help  ;)
Title: Re: How to set the current state for menu ?
Post by: Farhad Sakhaei on March 25, 2008, 11:29:41
Active menu item is an item that currently clicked on it and the related content is displayed ...
So you can have one activated menu item in the same time ... Not 2 menu item ...
Title: Re: How to set the current state for menu ?
Post by: Ivan Trebješanin on March 25, 2008, 11:50:30
Farhad was faster... :)
The whole active menu item system is made to help user understand better where he is. And as Farhad said, you cannot be at two places at once....
However, if you, for some reason insist on this, you can find a solution trough css.
Title: Re: How to set the current state for menu ?
Post by: Farhad Sakhaei on March 25, 2008, 13:13:06
As i know activation of a menu item , uses a code in file : /modules/mod_mainmenu.php

Code: [Select]
//Active Menu highlighting
$current_itemid = $Itemid;
if ( !$current_itemid ) {
$id = '';
} else if ( $current_itemid == $mitem->id ) {
$id = ' id="active_menu'.$params->get( 'class_sfx' ).'"';
} else {
$id = '';
}

The code adds an id with name : active_menu to current menu item , so if we click on a menu item on a menu , the code assigns this id to A tag of menu item dynamically , like this :
Code: [Select]
<a href="index.php?option=com_content&amp;task=section&amp;id=4&amp;Itemid=16" title="Discover Elxis" class="mainlevel" id="active_menu">Discover Elxis</a>
The id="active_menu" property shows us that this menu item is our active menu item , this help us that we can style it through a css style ...
And other menu items remains without any id , like this :
Code: [Select]
<a href="index.php?option=com_content&amp;task=view&amp;id=31&amp;Itemid=26" title="The Elxis license" class="mainlevel">The Elxis license</a>
You can review codes of /modules/mod_mainmenu.php file and write some hack for it if you want , for example adding another id or same id to parent menu item , and finally assign a css class for that id in your template css file ...  :)