Hi guys, a question - in order to prevent any mistakes design/coding.
I noticed that when I create methods to be displayed in templates, they sometimes appeared in the template, and sometimes not. I noticed that if they are present in the page class itself, it is fine. If a method is present in the controller, sometimes they appear and sometimes they don't (at least that's my observation so far).
Is it an issue if I am accessing a method of a class that I passed to the template via a DataObject::get clause (so not the currently running controller, of the page viewed). E.g. I have an aggregator page that parses Joomla articles. I reference this one in the controller of the HomePage.php class like this:
...
public function JoomlaPage() {
$joomlaPage=DataObject::get("JoomlaAggregatorPage","URLSegment='joomla-aggregator'");
return $joomlaPage;
}
...
In the JoomlaAggregatorPage.php in the class JoomlaAggregatorPage_Controller I have:
...
public function Items($limit = 10) {
...
}
...
In the HomePage.ss template I then do:
<% control JoomlaPage.Items %>
$properties_of_items
<% end_control %>
I noticed I can access the properties of the page itself but the control block doesn't return anything. Scoping problem?
Any insight on this would be amazing :)