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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Can <% if %> Use Integers?


Go to End


2 Posts   781 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