Hey guys,
I have something I can't solve
<% control Children %>
gives me back all my children
And I can call all the methods of all those children,
but I can't reach the methods of the controller of the children
Is there a way to do that ?
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.
I tried further and further
Also tried to call the model from the controller
Isn't there are way
to get the model related to the controller with a call from a controller function and the controller related to the model calling from a model function ?
If you need to do that, there's something wrong with your design. The controller is responsible for everything that happens in the view (template). But the model is responsible for manipulating and retrieving records from the database.
As a general rule, if the function is going to be used in more than one template, put it in the model. Otherwise, it goes in the controller. The template, you'll notice, can actually call functions from either class.
Thanks for the anwer :D
Well till now I guess my design isn't that well thought-out, that's true.
To what you are saying. I would love to call the controller function from the template, but I can't reach the childrens controller. This below doesn't work.
<% control Children %>
<% control AChildFunctionInChildController %>
<% end_control %>
<% end_control %>
Thus I thought, maybe I can reach the childrens controller functions through a Model function of the child
Or does this wish also mean that my design must be crap ^^ ?
Yeah, when you loop through the children, you're accessing them as a model, not as a controller. The controller is a set of functions for only the current template. Just move the functions you want to use in those objects from their controller to the model, and you should be fine.