I have a Route that activates a Controller which returns to me a page through a View. Let's call it master page.
route -> controller -> view [master page]
The master page is divided into header, sidebar, body and footer. And as the sidebar can be loaded to other pages, and not only the master page, it has its own View file.
However, the sidebar should receive the data from user, which would be obtained through a Model. And in theory, the Model could only be called by a Controller, who call the View, however, this View is the master page, not the sidebar.
[...] -> view [master page] -> view [sidebar]
So I thought the possibilities were as follows, and the idea is to know whether it is right or wrong, or perhaps it is another way that I could not imagine.
- The Controller will load the data from the Model and apply the sidebar which, in turn, be applied to the master page. The problem here is, in a "deeper" case, it would be extremely laborious and difficult to understand.
- The Controller run the Model, but send to the master page, which would be responsible for loading the View sidebar and pass the information of the Model to it. In this case, the work would be passing on information between the layers, so far as was necessary to take the information.
- The Controller will only load the View master page, which will load the sidebar, which will be responsible for executing the Model (inside View). The problem here is that a View theoretically should not run a Model, just print your information already processed in the Controller.
What would be the most appropriate way to make this process run correctly?
Controller -> MasterPage View -> Sidebar Controller -> Sidebar View -> Controller Avatar -> Avatar View
. – David Rodrigues Jul 20 '14 at 2:42MasterPage View
just gets theSidebar
it needs from its Controller and doesn't care where it came from. A more in-depth discussion can be found at techportal.inviqa.com/2010/02/22/… – Bart van Ingen Schenau Jul 20 '14 at 9:05