Page 1 of 1

Solved: More than one #active in a menu (J! 1.0.13)

Posted: Fri Jan 25, 2008 12:44 pm
by 5v€n
Hi,

i have hacked my mod_mainmenu.php so I can add to each menu item in a menu a personal suffix, because i want to have for every item another :link, :hover ,... graphic. Now i have the problem, that my #active_menu graphic is at all menu items the same - and this is bad :)
Therefor i want, that the suffix i gave the menu item is at the end of #active_menu, too.

A short example:
My suffix for the menu item Bla is _bla. Now i want, that _bla is used for the #active_menu... looks like that: #active_menu_bla
so, i think, i can give every menu item another #active_menu graphic.

But i don't know which line i have to edit in the mod_mainmenu.php. i get the suffix with $css_params->get('item_sfx');

I hope someone can help me :)

thx.
sven

Re: Solved: More than one #active in a menu (J! 1.0.13)

Posted: Thu Jan 31, 2008 8:37 pm
by floydiology
If you solved it...what did you do to solve it, dont just edit your answer removing the solution, share with us?

Re: Solved: More than one #active in a menu (J! 1.0.13)

Posted: Thu Feb 07, 2008 2:19 pm
by 5v€n
OK.. ;)
it's quite simple.
at first I edited the XML of the different link types like content_blog_section in administrator/components/com_menu/
there you have to add the line

Code: Select all

<param name="item_sfx" type="text" default="" label="Item Suffix" description="For every menu point a seperate css class" /> 

with this line you get a form field where you can add a suffix.

the second step is to add some lines in the mod_mainmenu.php in /modules/


function mosGetMenuLink( $mitem, $level=0, &$params, $open=null ) {
global $Itemid, $mosConfig_live_site, $mainframe;

$txt = '';

$css_params = new mosParameters( $mitem->params ); //ADD THIS

switch ($mitem->type)..
------------------------
// Active Menu highlighting
$current_itemid = $Itemid;
if ( !$current_itemid ) {
$id = '';
} else if ( $current_itemid == $mitem->id ) {
$id = 'id="active_menu'. $css_params->get('item_sfx') . $params->get( 'class_sfx' ) .'"'; //CHANGE IT LIKE THAT!
} else if( $params->get( 'activate_parent' ) && isset( $open ) && in_array( $mitem->id, $open ) )  {
$id = 'id="active_menu'. $css_params->get('item_sfx') . $params->get( 'class_sfx' ) .'"'; //CHANGE IT LIKE THAT

---------------------------
if ( $params->get( 'full_active_id' ) ) {
// support for `active_menu` of 'Link - Component Item'
if ( $id == '' && $mitem->type == 'component_item_link' ) {
parse_str( $mitem->link, $url );
if ( $url['Itemid'] == $current_itemid ) {
$id = 'id="active_menu' . $css_params->get('item_sfx') . $params->get( 'class_sfx' ) .'"';//CHANGE IT LIKE THAT!

--------------------------------
// run through SEF convertor
$mitem->link = sefRelToAbs( $mitem->link );

$menuclass = 'mainlevel'. $params->get( 'class_sfx' ) . $css_params->get('item_sfx'); //ADD
if ($level > 0) {
$menuclass = 'sublevel'. $params->get( 'class_sfx')  . $css_params->get('item_sfx');//ADD
}


Ok. That's it.. now you can give every menu item a different suffix. and #active_menu changes to #active_menu_suffix
the changes are only for content_blog_section
if you want the feature in other link types you have to add it in the xml file of the link type.