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

Can <% if %> Use Integers?


Go to End


2 Posts   1426 Views

Avatar
BobRock

Community Member, 15 Posts

5 September 2013 at 1:56am

Edited: 05/09/2013 1:56am

I'd like to use a template conditional based on an integer return like this:

 <% if $Variable.count = 1 %> 

Is that possible? It doesn't seem to work when I try it and the documentation talks only about literals inside "" with ==.

Bob

Avatar
BobRock

Community Member, 15 Posts

5 September 2013 at 6:13am

Edited: 05/09/2013 6:13am

With some help from Stack Overflow, the answer is yes, but you have to do it right:

 <% if $Variable.count == 1 %> 

Note that that's two =.

Bob