Page 1 of 1

Menu. Need help!

Posted: Wed Nov 06, 2013 4:49 pm
by 14m3r
Listen, guys, does anyone know how to add in menu template additional tags <span class='right'><span class='tail'> for child menu items and class="last-item" for last items?
Before me there is a task to make here such structure:

Code: Select all

<ul class="sf-menu">
	<li class="current"><a href="">Menu Item 1 (default current)</a></li>
	<li><a href="">Menu Item 2 (section header)</a>
	    <ul>
		<li><a href=""><span class="right"><span class="tail">SubMenu Item 1</span></span></a></li>
		<li><a href=""><span class="right"><span class="tail">SubMenu Item 2 (section header)</span></span></a>
		    <ul>
			<li><a href=""><span class="right"><span class="tail">SubSubMenu Item 1</span></span></a></li>
			<li><a href=""><span class="right"><span class="tail">SubSubMenu Item 2</span></span></a></li>
			<li class="last-item"><a href=""><span class="right"><span class="tail">SubSubMenu Item 3 (last-item)</span></span></a></li>
		    </ul>
		</li>
		<li class="last-item"><a href=""><span class="right"><span class="tail">SubMenu Item 3</span></span></a></li>
	    </ul>
	    </li>
	<li><a href="">Menu Item 3</a></li>
	<li><a href="">Menu Item 4</a></li>
	<li class="last-item"><a href="">Menu Item 5</a></li>
</ul>

Re: Menu. Need help!

Posted: Thu Nov 07, 2013 3:46 am
by chandra
You can check the last item with variable {$node@last} where $node must be the item variable used inside the MenuManager foreach loop.

Re: Menu. Need help!

Posted: Thu Nov 07, 2013 7:41 am
by velden
Read the help of Menu Manager:
$node->depth -- Depth (level) of this node in the current menu
Don't know if depth starts at 0 or 1, but you could do some conditional things inside the menu manager template:

Code: Select all

Just an example.
Assumes that $node->depth starts at 1

{if $node->depth > 1}
<span class="right"><span class="tail">{/if}{$node->menutext}{if $node->depth > 1}</span></span>{/if}
$node->first -- exists, and set to 1 if is the first item in a level.
$node->last -- exists, and set to 1 if is the last item in a level.

Re: Menu. Need help!

Posted: Thu Nov 07, 2013 1:26 pm
by 14m3r
Thank you, guys. I'll try your suggestions. ;)