I’m trying to learn how to make a PHP app using an MVC architecture. I’ve created a basic app based on a tutorial which just has a model, a view and a controller for each page group (such as site.com/index, site.com/account and so on).
My problem now, is that I can’t figure out how I would make something more complex. Say, I want to make a calendar app, in which the user sees a calendar on their account page when they log in.
Would I create a model and view for the calendar, and then get the required calendar data by including the calendar model into the account page controller?
How about when rendering the calendar, would I include the calendar view into the account page view and then use that to generate my calendar layout?
You have a pretty good idea i would say. Think of the calendar view as a “partial view” basically it’s not a full html page, just the calendar in a div. You would include this partial view within the account view and pass in the data as needed. Yes, you can grab the calendar data in the account controller using the calendar model, this data can then be sent to the account view and further passed on to the partial calendar view.