I need somethig like this:
<% if Photo.Orientation == 1 %>
$Photo.$SetHeight(200)
<% else_if %>
$Photo.$SetWidth(200)
<% end_if %>
Dont work!
Can anybody help me?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
I need somethig like this:
<% if Photo.Orientation == 1 %>
$Photo.$SetHeight(200)
<% else_if %>
$Photo.$SetWidth(200)
<% end_if %>
Dont work!
Can anybody help me?
Hi!
I don’t know where this Orientation propriety is coming from (I guess you added it to the Photo class) but your code will never work if you don’t remove the $ before SetHeight and SetWidth.
Hope it helps,
Juan
$Image.Orientation - It's a SilverStripe property ( http://doc.silverstripe.org/doku.php?id=image ).
It returns 1 if image vertical, and 2 - if horizontal. And I can't work with this values in my template, like this
<% if Photo.Orientation == 1 %>
$Photo.SetHeight(200)
<% else_if %>
$Photo.SetWidth(200)
<% end_if %>
and Photo:
static $has_one = array(
'Photo' => 'Image'
);
One '=' in you comparison statement!
<% if Photo.Orientaion = 1 %>
....
<% else %>
....
<% end_if %>
Still don't work!
And in SS templates for comparision use ==
(http://doc.silverstripe.org/doku.php?id=templates&s=property)
Nope. It's = in templates (not ==).
Maybe try the following:
<% control Photo %>
<% if Orientation = 1 %>
$SetHeight(200)
<% else_if %>
$SetWidth(200)
<% end_if %>
<% end_control %>
Thank you, banal! It works!
This is full working code:
<% control Photo %>
<% if Orientation = 1 %>
$SetHeight(200)
<% else %>
$SetWidth(200)
<% end_if %>
<% end_control %>