Page 1 of 1
in native templating / mvc who should load includes?
Posted: Wed Aug 23, 2006 5:23 pm
by alvinphp
In a native templating mvc type architecture is it better to have
1. my controller load header.php, mypage.php, and footer.php
OR
2. my controller load mypage.php and that page loads my header and footer include pages?
OR
3. I am just being anal.
Posted: Wed Aug 23, 2006 5:27 pm
by alvinphp
I am thinking 1 is the best method as it best seperates business logic with the presentation layer.
Posted: Wed Aug 23, 2006 5:30 pm
by Chris Corbyn
I'm thinking number 0.
Front Controller can load in header and footer, as well as the correct page controller. The page controller can then load in mypage.php.
Posted: Wed Aug 23, 2006 5:36 pm
by alvinphp
d11wtq wrote:I'm thinking number 0.
Front Controller can load in header and footer, as well as the correct page controller. The page controller can then load in mypage.php.
Not using a front controller and do not want to in my particular situation. So, I would say you are more with 1 where the controller loads the include pages. Thanks!
Posted: Wed Aug 23, 2006 5:51 pm
by Chris Corbyn
alvinphp wrote:So, I would say you are more with 1 where the controller loads the include pages. Thanks!
Yes, I sway toward 1

If the header and footer are the same on each page (with maybe the exception of a button highlighted on a per-page basis) I would consider refactoring a little to centralize the loading of the header and footer however

Posted: Wed Aug 23, 2006 6:32 pm
by AKA Panama Jack
Actually number 2 would be the better way to go. This will allow you to have DIFFERENT headers and footers. It will allow far more control over what is being displayed.
Posted: Wed Aug 23, 2006 6:41 pm
by alvinphp
d11wtq wrote:alvinphp wrote:So, I would say you are more with 1 where the controller loads the include pages. Thanks!
Yes, I sway toward 1

If the header and footer are the same on each page (with maybe the exception of a button highlighted on a per-page basis) I would consider refactoring a little to centralize the loading of the header and footer however

This is assuming every page/module uses the same header/footer. Granted, you can have the controller decide what header to use (if at all). Do not get me wrong, I love the front controller pattern and use it quite extensively already.
Posted: Wed Aug 23, 2006 6:48 pm
by alvinphp
AKA Panama Jack wrote:Actually number 2 would be the better way to go. This will allow you to have DIFFERENT headers and footers. It will allow far more control over what is being displayed.
That is true, plus some includes might have to be integrated inside a main page where you need to add the include inside mypage.php versus a header/footer which goes on the top/bottom of the page and is easy for a controller to handle. Hmmm, maybe I will stick with 2. I would like includes to all happen in the same place as it makes it easier for me to work with the code.
Posted: Thu Aug 24, 2006 3:08 am
by Jenk
If you are using a template engine ala Smarty, it would be the template that loads the header/footer and if there is any specific logic for it, the controller for that template would load the logic (as well as the template include the template for it)