1
votes

I've written a simple custom function to take care of more than (>) This works fine and returns 1 or 0.

It stops working when I pass $Pos to the function when it's called withing a loop.

SilverStripe Version 3

Controller

  function MoreThen($pos, $value) {
if($pos > $value) {
  return TRUE;
} else {
  return FALSE;
}

}

Template.ss

<% loop GalleryObjects %>
 <% if Top.MoreThen($Pos,2)  %>
$Pos
<% end_if %>
1
You can create a custom template iterator: [$Pos from bottom inside <% loop DataObjects %>][1] [1]: stackoverflow.com/questions/14096216/…Olli Tyynelä

1 Answers

3
votes

AFAIK it is not possible to use variables as arguments of function calls, only concrete values. Depending on what you want to do, you might want to look at using GalleryObjects.limit() in your template, or write a specific getter that would return only GalleryObjects with an offset greater than 2. Hope this helps