Jump to content

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();
}

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.