How to add "first" and "last" CSS classes to mod_menu?

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.
Roues
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Sat Jul 23, 2011 11:06 am

Re: How to add "first" and "last" CSS classes to mod_menu?

Post by Roues » Sun Apr 15, 2012 10:43 pm

huntkey wrote:

Code: Select all

$last_items = array();//all last item IDs

for($j=count($list); $j>0; $j--){
	if(!isset($last_items[$list[$j]->parent_id])){
		$last_items[$list[$j]->parent_id] = $list[$j]->id;
	}
}

$first_start = true;//using for first item of level 1 menu and submenu
This code in my case is not working properly when the size of the array does not correspond to the maximum key!

For proper placement of the 'last' classes for menu items, I replaced the above code on such:

Code: Select all

$last_items = array();//all last item IDs

foreach ( array_reverse ( $list, TRUE ) as $v ) {
	if ( !isset ( $last_items[$v->parent_id] ) )
		$last_items[$v->parent_id] = $v->id;
}

$first_start = true;//using for first item of level 1 menu and submenu

w9914420
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Tue Oct 23, 2007 10:58 pm

Re: How to add "first" and "last" CSS classes to mod_menu?

Post by w9914420 » Mon May 07, 2012 12:25 pm

Hi Roues,
I have just managed to get chance and try your code works brilliantly!

:D

thanks again for your input.

w9914420

User avatar
humvee
Joomla! Master
Joomla! Master
Posts: 14704
Joined: Wed Aug 17, 2005 10:27 pm
Location: Kent, England

Re: How to add "first" and "last" CSS classes to mod_menu?

Post by humvee » Mon May 07, 2012 4:51 pm

[Mod note: Moved from General Forum to Overrides Forum.]


Locked

Return to “Templates for Joomla! 2.5”