Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Position of Menu Item


Go to End


4 Posts   2672 Views

Avatar
svinkle

Community Member, 16 Posts

4 February 2009 at 8:13am

Is there any built in functionality that shows the current position of a menu item within the Menu control? I need to output a specific class name for a list item if the link being output is first in the list.

If there's no built in functionality I'm sure it's possible through Page.php. I am just looking for an easy solution first.

Avatar
dio5

Community Member, 501 Posts

4 February 2009 at 9:16am

Hey,

I think $Pos is available, it'll give you the position of the iterator.

Avatar
Nathan Cox

Community Member, 99 Posts

4 February 2009 at 4:18pm

You can also use something like:

<li class="<% if First %>firstItem<% end_if %>">
...stuff...
</li>

Take at look at http://doc.silverstripe.com/doku.php?id=built-in-page-controls#dataobjectset_options for more info.

Avatar
svinkle

Community Member, 16 Posts

5 February 2009 at 3:38am

I went with the <% if First %> solution. It worked perfectly. Thanks!