Answer the question
In order to leave comments, you need to log in
mvc architecture + modules, how to do it right?
There is an application with mvc architecture + modules that can be called in templates and get the necessary content.
The following question arose - for example, on the page site.ru/news/its-first-news-url
I want to view the news in its entirety. But first, in the controller, I get information on this news in order to set the title, description, keywords, and so on. That is, I am already turning to the database on this news. Next, in the news output template, I call the "News" module with the "url news" parameter. Accordingly, the module searches the database for news with the url of this news and returns html.
Everything seems to be fine, but in order to show the news, you have to climb into the database 2 times for the same, in fact, request. How can you get rid of this?
As an option, transfer information on the page from the controller to the template, and in it, information on the page is already in the module. But then there will be a rigid binding of the module to the controller, which, in my opinion, is not good.
What is the right way to do it here? If possible - links or descriptions of your solutions, thanks!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question