I'm struggling to get something that should be simple to work. I was trying the following in a silverstripe template file without success :
<% if $objectCount > 10 %>
I have read on the silverstripe another person having the same problem with no satisfying answer ( http://www.silverstripe.org/template-questions/show/10053 ) So I wanted to come up with a alternative in the meantime other than a basic method :
<% if $objectCountGreaterThanTen %>
So I've implemented a simple class hiding the conditional logic as follow :
class EvaluateLogic extends DataObject {
public function greaterThan($exp, $x) {
print_r('calling logic.greaterThan()');
return $exp > $x;
}
public function lessThan($exp, $x) { return $exp < $x; }
...
}
Then I instantiate an EvaluateLogic member ( named $logic ) in the DataObject class I use in the template by doing this :
<% if $logic.greaterThan($objectCount, 10) %>
but the .greaterThan() call is being ignored for some reasons.. Which I don't understand ? To partition the issue I have created a getLogic() accessor in my DataObject to also print some thing and see if the code was reached, which it is, but then the print_r in the greaterThan() function is not called.
Any ideas how to make this work ?
Thanks