works fine in my test.
check your image size and maybe add some print functions in the controller function to check.
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.
- Previous 10 entries
- 1
- 2
- 3
- Page 44(current)
- 5
- Next 10 entries
The issue is that I'm calling the function within the scope of Images that I've setup with a many_many because of the SS bug.
Maybe use SS 3.0.1 RC2
I don't think it was fixed in that RC according to the change log.
It's more of a scope issue. I don't know how to call the function within the Image loop. I've tried $Top in some places, but so far nothing.
if you are in the loop, use $Up to move one level up in the scope. Which should make something like <% if $Up.greaterThan($Width, 800) %>
all the answers are here http://doc.silverstripe.org/framework/en/reference/templates
I had originally tried that with $Top and no luck. Same goes for $Up.
If I use your function outside of the Images loop it returns correctly
See anything wrong with this:
public function greaterThan($value, $reference) {
if ($value > $reference){
return true;
}
else{
return false;
}
}
<% loop Images %>
<% if $Up.greaterThan($Width, 800) %>
<a href="$SetWidth(800).URL" class="itemPhotos <% if MultipleOf(5) %> itemPhotosLast <% end_if %>" title="$Title">$CroppedImage(158,158)</a>
<% else %>
$Width
<% end_if %>
<% end_loop %>
I'm just putting $Width in the else block to see how it returns. It always returns false and I have images both smaller and larger than 800. I've tried $Up, $Top and at the front and end of the function just to test. Nothing works. Always false.
$Up seems to work fine on my setup.
can you attached your files, Model, Controller and Template?
Here is the php - http://pastebin.com/g0dMJL0w
Here is the template - http://pastebin.com/nH4N6uu4
- Previous 10 entries
- 1
- 2
- 3
- Page 44(current)
- 5
- Next 10 entries