drcphd Posted September 6, 2007 Share Posted September 6, 2007 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 : ) Quote Link to comment Share on other sites More sharing options...
Eric_Ryk Posted September 7, 2007 Share Posted September 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
448191 Posted September 7, 2007 Share Posted September 7, 2007 You can have one controller execute multiple commands. Encapsulate the the commands in Command objects to avoid repeating logic. Quote Link to comment Share on other sites More sharing options...
Mastodont Posted September 7, 2007 Share Posted September 7, 2007 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(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.