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

SOLVED - How to use Orientation in control <% if?


Go to End


2 Posts   1606 Views

Avatar
dominicB

Community Member, 14 Posts

3 September 2010 at 8:47pm

Edited: 03/09/2010 8:51pm

This is what I want to do:

<% if ImageFile.Orientation = 2 %>
$ImageFile.SetWidth(135)
<% else %>
$ImageFile.SetHeight(135)
<% end_if %>

I can use $ImageFile.Orientation outside if the <% %> and it prints on the screen nicely. But If I try and use it inside <% %> the template breaks.
Do I have the wrong syntax? I've tried every variation I can think of. Or is it just not possible? I know I can get around this by adding a method into the controller but it's annoying to have to do that when I can print the Orientation property onto the page.

Avatar
dominicB

Community Member, 14 Posts

3 September 2010 at 8:51pm

I found the answer here:

http://www.silverstripe.org/template-questions/show/272774#post272774

it's

<% control ImageFile %>
<% if Orientation = 2 %>
$SetWidth(135)
<% else %>
$SetHeight(135)
<% end_if %>
<% end_control %>