proxi — 2010-04-09T15:26:45-04:00 — #1
How do you guys handle includes for html that gets repeated through many pages while keeping MVC in mind?
IE. Footers, side navigation, etc etc.
Do you just do a include? Or assign a variable to hold the include and echo it out in the html side?
oddz — 2010-04-09T17:52:56-04:00 — #2
I separate out things like that into their own controller making it possible to reuse them anywhere.
proxi — 2010-04-09T18:00:05-04:00 — #3
Actually I was just thinking about it, and my logic was off a bit. I was separating pages into individual ones even though I could have just done something like: domain.com/page/view/other/params
PS. Didn't mean to hijack the thread
mastodont — 2010-04-10T03:01:33-04:00 — #4
Footers, side navigation etc. may contain dynamic parts, dependent on main content ... so separate controller bound to some Context dispatcher is a way to go.
vali — 2010-04-10T11:31:22-04:00 — #5
Try to never have any duplicated code in your site.
If you have a header on 2 pages, then make it an include.
If your selected page needs to be highlighted, then add that code in the included header.
Do this until you learn more PHP and get some experience with websites.
After you make a few sites, you will notice the need for front controllers (chances are so far your using page controllers).
sunwukung — 2010-04-27T06:57:22-04:00 — #6
I have nested view objects:
1: make a master view for whole app - kick off output buffering on app startup
2: nominate a master layout template
3: inject view helper into each controller class - start new output buffer
4: render controller output into the view for that controller
5: flush controller view output into a variable
6: render that variable into the master template