RossMcCaughrain Posted May 18, 2009 Share Posted May 18, 2009 Hi All, Ok so i know theres loads of php MVC products out there but Im writing my own version of the MVC pattern purely for the learning benefit and so i understand it! Anyway i have a couple of quick design question in which im looking for the best or most common approach to solve. So the questions are: If my sections are mainly logically separate units e.g. Home, Guestbook, Site News, Users etc with a controller, model and view for each but on the home page i want to display a range of information from each section e.g. latest headlines, latest members, latest posts what is the best way to do this? Theorys i have are: [*]Bypass each units controllers and go straight to their model e.g. HomeController calls methods in NewsModel returns the data and renders it [*]Keep it logically separate and write a HomeModel that contains the relevant db calls to the other units [*]Some other weird and wonderful way i havent though of! And additionally if i have a front controller that is processing and directing all my requests to the required controller which is processing the data and rendering a template what is the best way to process ajax requests? Am i over complicating and should just have the server side method just echo back to the ajax script or should i append a GET param of callType=ajax and process differently? I know design is never an exact science but am just curious what ideas/suggestions are out there! Cheers all! Ross Quote Link to comment Share on other sites More sharing options...
GKWelding Posted October 9, 2009 Share Posted October 9, 2009 Ross, With regards to point 1, both the first two points are perfectly acceptable. However, for ease and the fact it's much more flexible, I would bypass the controller and call the model directly returning an array of data to do what you like with. Secondly, I would go down the route of processing ajax requests differently, as if you process them the same then you'll be loading the framework every time when you really don't need to. I hope some of this helps. 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.