pakmannen
08-27-2007, 03:02 PM
Hi!
I've been checking out articles about the MVC design pattern recently, and tried to implement a very basic one myself. Everything has been going relatively smoothly with the models and the views, but I've got a few questions about the controller aspect. Hope someone here is willing to enlighten me. :)
First of all, one basic thing that isn't mentioned in any of the articles I've read concerns using multiple models on a page. I don't know if I've failed to grasp something here but it seems obvious that you sometimes have to use more than one model on a page. Say, your website's front page where you list users (using the User model) news items (using the News model) etcetera. All this info needs to come together in a single "view" so to speak.
So, first question, are you supposed to be able to use more than one model per page?
Now, if that is the case, I don't see how you can implement this using a single controller (index.php) which gets its info from the URL (as in, model=foo&method=bar) like some of the articles I've read does. Well I guess you could, but it would be a bit clunky.
However, other articles use a system where they have one controller for each view. Is this a better method?
I've been checking out articles about the MVC design pattern recently, and tried to implement a very basic one myself. Everything has been going relatively smoothly with the models and the views, but I've got a few questions about the controller aspect. Hope someone here is willing to enlighten me. :)
First of all, one basic thing that isn't mentioned in any of the articles I've read concerns using multiple models on a page. I don't know if I've failed to grasp something here but it seems obvious that you sometimes have to use more than one model on a page. Say, your website's front page where you list users (using the User model) news items (using the News model) etcetera. All this info needs to come together in a single "view" so to speak.
So, first question, are you supposed to be able to use more than one model per page?
Now, if that is the case, I don't see how you can implement this using a single controller (index.php) which gets its info from the URL (as in, model=foo&method=bar) like some of the articles I've read does. Well I guess you could, but it would be a bit clunky.
However, other articles use a system where they have one controller for each view. Is this a better method?