Reputation: 2729
I would like to run a function with an if statement in the template file.
It should be easy enough but when add the function within the if statement nothing is returned.
The function and conditional statement works as I can call the function outside of the conditional statement and the other data within the conditional state are returned.
page.php
class Page_Controller extends ContentController {
public function thisIsAFunction() {
return "I am a function";
}
}
page.ss
Hello, $thisIsAFunction
Result:
Hello,
Upvotes: 0
Views: 1959
Reputation: 81
If $thisIsAFunction
is outputting the correct value elsewhere, it sounds like there may be a scope issue. Ensure that you're not inside a <% with %>
or <% loop %>
block as these change scope - if so, use $Top.thisIsAFunction
.
Upvotes: 4
Reputation: 1
Try putting your function in the Page class rather than the Page_Controller.
Upvotes: 0