Jump to content

MVC: multiple controllers simultaneously?


drcphd

Recommended Posts

I'm planning on writing my own simple MVC (model-view-controller) framework but I have a question.

 

Let's say I have two controlles/modules: 'news' and 'polls'.

On the page that displays news, I also want a box with a poll.,

Or let's say I always want a 'web_links' controller displayed on the bottom of the page?

 

Do MVC frameworks generally have a procedure for this?

 

Should I instantiate two controllers? Or is there a preferable method?

 

Thanks in advance.

 

 

PS: I'm not too familiar with these frameworks yet, but I'm learning : )

Link to comment
https://forums.phpfreaks.com/topic/68287-mvc-multiple-controllers-simultaneously/
Share on other sites

What you can do is have the news controller call upon the polls controller through some means. In terms of cases where you have things displayed on every page, perhaps you could set up some form of a "global" or "layout" controller that is called every load, and works out those kinks by calling other controllers itself.

On the page that displays news, I also want a box with a poll.

 

So you have page with some blocks, each block has assigned content. You need some mechanism for mapping current blocks' content to URL. Then you can iterate blocks and call methods for fetching data. Somethïng as:

 

foreach ($blocks as $block) {
    $component = new Mapper->component($block);
    $output['block'] = $component->Fetch();
}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.