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.

Themes /

Discuss SilverStripe Themes.

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

Template Menu Control $Pos and $TotalItems


Go to End


4 Posts   3079 Views

Avatar
Bandit

Community Member, 10 Posts

4 December 2010 at 9:08pm

Hey guys

I have a menu control where I want to show an element after each menu item unless it's the last one.

The following code seems like it should work but doesn't:

<% if Pos != TotalItems %>|<% end_if %>

It outputs whatever is inside the if statement, even when $Pos and $TotalItems are equal.

Any ideas?

James

Avatar
dhensby

Community Member, 253 Posts

5 December 2010 at 12:12am

I think what you are trying to do is:

<% if Last %><% else %>|<% end_if %>

You cant compare two template variables like in your example. The template parser assumes the rhs of the statement is a string, not a var.

Hope that solves it

Avatar
Bandit

Community Member, 10 Posts

5 December 2010 at 12:24am

Ah cool - will give that a try. Where are things like "Last" documented?

Avatar
dhensby

Community Member, 253 Posts

5 December 2010 at 12:29am

http://doc.silverstripe.org/built-in-page-controls

See quick reference at the bottom.