active item: impossible to style differently for 2 menus

Everything to do with Joomla! 2.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
teapotbag
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Mon Nov 08, 2010 2:39 am

active item: impossible to style differently for 2 menus

Post by teapotbag » Mon Mar 14, 2011 12:36 am

I have two menus, styled very differently.

I need to make the current active menu item stand out, but obviously, I have to apply different css styles to the active items in the two different menus.

I was able to do this in 1.5, but it seems impossible in 1.6, because the menu structure has changed.

It looks like this:
<ul class="menu-suffix">
<li id="item-25" class="current active">
<a href="link">ITEM</a>
</li>
The suffix is only added to the whole menu, but no longer to individual item classes. So the classes "current" and "active" are given to an active menu item, regardless which menu it belongs to. There is no way to style them separately for each menu!?

Any solutions for this?

I'm thinking it should look like this:
<li id="item-25" class="current-suffix active-suffix">

and I believe this is defined in modules/mod_menu/tmpl/default.php, but I don't know how to tweak that php myself?

If anyone can help I would be sooo grateful!
Last edited by teapotbag on Mon Mar 14, 2011 2:19 am, edited 2 times in total.

teapotbag
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Mon Nov 08, 2010 2:39 am

Re: active item: impossible to style differently for 2 menus

Post by teapotbag » Mon Mar 14, 2011 1:21 am

OH wait! I've figured it out! (copied the php from the 1.5 module file :D and woohooo it works!)

If anyone needs this in the future, in modules/mod_menu/tmpl/default.php around line 23

change

Code: Select all

	if ($item->id == $active_id) {
		$class .= 'current ';
	}

	if (in_array($item->id, $path)) {
		$class = 'active ';
	}

to

Code: Select all

	if ($item->id == $active_id) {
		$class .= 'current' . $params->get('class_sfx') . '"';
	}

	if (in_array($item->id, $path)) {
		$class = 'active' . $params->get('class_sfx') . '"';
	}

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44068
Joined: Sat Apr 05, 2008 9:58 pm

Re: [S] active item: impossible to style differently for 2 m

Post by Webdongle » Mon Mar 14, 2011 1:29 am

Just a few minor points

Would it be better to create a Template override than just edit a core file ?

Does
$this->escape code
need to be in there somewhere ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

teapotbag
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Mon Nov 08, 2010 2:39 am

Re: [S] active item: impossible to style differently for 2 m

Post by teapotbag » Mon Mar 14, 2011 1:40 am

Yeah I turned it into an override just now, I was just about to go back to edit to say that. :)

I have no idea about $this->escape, I really don't get much php, I copied that string of code like a dummy and well, it works great!

:D

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44068
Joined: Sat Apr 05, 2008 9:58 pm

Re: [S] active item: impossible to style differently for 2 m

Post by Webdongle » Mon Mar 14, 2011 2:08 am

$this->escape
Is something to do with preventing SQL injection me thinks. It is included in a lot of default.php overrides.

It appears in
templates/beez5/html/com_content/article/default.php

Not sure if it needs to be in the modules override ?

Was hoping someone who new the answer would confirm the 'safety' of the code you copied.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

teapotbag
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Mon Nov 08, 2010 2:39 am

Re: [S] active item: impossible to style differently for 2 m

Post by teapotbag » Mon Mar 14, 2011 2:18 am

woops!

You may be right, I've no idea.

Ok... anyone know this?

Think I'll remove the "solved" tick from the thread for now...


Locked

Return to “Templates for Joomla! 2.5”