Hello,
I have created an application that uses a Router, or Front-Controller if you like, to dynamically load an MVC triad. The Router uses static routing, i.e. every URL is listed in an array and corresponds to a set of properties. I know some think it a disadvantage, but in my case there are other considerations that require this method to be implemented.
So far I can get away with using one MVC triad per ‘page’, but I assume this will soon become an obvious limitation.
I’d like to ask for an advice, how would you use the Router (or Front-Controller) to load several MVC triads, and how would you instantiate and switch between them?
My direction of thought is looping through an MVC array, each time instantiating a different triad, and running it. The view would add the output to some $content variable. When done looping that would be injected into a template and sent back.
But how would I have the view change it’s model on the fly, based on an instructions from the Router? Because If I instantiate a different triad every time, I would have problems passing variables in a flexible way between each triad.
Any thoughts?