17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2709 Views |
-
How to call controller functions from the model?

8 December 2008 at 2:25pm Last edited: 8 December 2008 2:25pm
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 ? -
Re: How to call controller functions from the model?

8 December 2008 at 6:40pm
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 ? -
Re: How to call controller functions from the model?

9 December 2008 at 3:50am
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.
-
Re: How to call controller functions from the model?

9 December 2008 at 4:28am Last edited: 9 December 2008 4:30am
Thanks for the anwer
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 ^^ ? -
Re: How to call controller functions from the model?

9 December 2008 at 4:36am
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.
| 2709 Views | ||
|
Page:
1
|
Go to Top |

