Menu. Need help!

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
14m3r

Menu. Need help!

Post 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>
chandra

Re: Menu. Need help!

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Menu. Need help!

Post 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.
14m3r

Re: Menu. Need help!

Post by 14m3r »

Thank you, guys. I'll try your suggestions. ;)
Locked

Return to “CMSMS Core”