Answer the question
In order to leave comments, you need to log in
Persistent content in MVC web frameworks?
Suppose we have a website running on one of the MVC frameworks. There are a lot of entities and pages on the site. But the pages always show a side column with a block displaying random images from the site.
The question is, according to the MVC paradigm, data should be pulled from the model in the controller and passed to the view, should it be the same in this case?
Or is it worth getting the data exactly where they are used, bypassing the controller?
Answer the question
In order to leave comments, you need to log in
One implementation option is to use widget logic. Those. have a plug-in library that implements MVC already in itself.
The second option is to use a more complex renderer than the framework offers. In the renderer, describe the logic for displaying sidebars and generally assemble the page template from separate parts.
If you want to keep architectural purity, then you should probably take a closer look at PAC / HMVC
Who told you such nonsense that models should give data _only_ through the controller? In Zend, for example, there are models that work bypassing the controller, and they are called view helpers. The same above plugins are also essentially models.
The controller is not a postman that passes data from the model to the view, but an independent component that implements business processes.
If no business process is associated with the display of a certain block, then it does not need a controller at all.
If the sidebar is shown everywhere, you can stick your base controller between the base controller of the framework and the working controller.
And there already to extract the contents of the sidebar.
Well, if the framework allows this, of course.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question