How to get the last item in the menu

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.
Post Reply
blue_francis14
New Member
New Member
Posts: 3
Joined: Wed Apr 01, 2009 3:24 pm

How to get the last item in the menu

Post by blue_francis14 »

Hello,

I am currently using CMSMS 1.5.1 and I am trying to achieve this navigation

Home | About Us | Contact

Unfortunately, it's always displaying an extra pipe at the end


Home | About Us | Contact |

Is there a way to do this? Like {$node->last_item}?

Thanks in advance!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: How to get the last item in the menu

Post by calguy1000 »

Read the smarty manual.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: How to get the last item in the menu

Post by Jeff »

How about just searching the forum. I have seen this request posted and answer multiple times within the last couple days.
blue_francis14
New Member
New Member
Posts: 3
Joined: Wed Apr 01, 2009 3:24 pm

Re: How to get the last item in the menu

Post by blue_francis14 »

I am not really sure what keyword to use to search this. The admin could put it in as a sticky if you have seen it asked a couple of times.
blue_francis14
New Member
New Member
Posts: 3
Joined: Wed Apr 01, 2009 3:24 pm

Re: How to get the last item in the menu

Post by blue_francis14 »

I read the smarty manual and got it to work. Here is the code

Code: Select all

{* CSS classes used in this template:
#menuwrapper - The id for the <div> that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the <ul>
.menuparent - The class for each <li> that has children.
.menuactive - The class for each <li> that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}
<div id="menuwrapper">
<ul id="primary-nav">
{foreach from=$nodelist item=node name=foo}
{if $node->depth > $node->prevdepth}
{repeat string="<ul class='unli'>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
<li class="menuactive menuparent">
<a class="menuactive menuparent" {elseif $node->current == true}
<li class="menuactive">
<a class="menuactive" {elseif $node->haschildren == true}
<li class="menuparent">
<a class="menuparent" {elseif $node->type == 'sectionheader'}
<li class="sectionheader"><span>{$node->menutext}</span> {elseif $node->type == 'separator'}
<li style="list-style-type: none;"> <hr class="separator" />{else}
<li>
<a {/if}

{if $node->type != 'sectionheader' and $node->type != 'separator'}
href="{$node->url}"><span>{$node->menutext}</span></a> 
{if $smarty.foreach.foo.last == 0} | 
{/if}
{elseif $node->type == 'sectionheader'}
><span>{$node->menutext}</span></a>
{/if}
{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}
</li>
</ul>
<div class="clearb"></div>
</div>
{/if}
Do you think there could be a better solution to this?
Post Reply

Return to “CMSMS Core”