How do you template your site?
Posted: Thu Sep 10, 2009 12:09 am
I was curious to know how the DevNeters design their php templates. What I mean by templates and templating in this case is how you re-use your code and markup. For example let's say you have a standard header area for your site. You could either copy and paste that header to the body of every page you create, or you could place the header within a separate file and include it on every page. The former solution is good if you want to be able to customize the header specifically for every page. The latter solution is much better because if you want to make global changes throughout your site you just change the header file, plus you can also make the header file dynamic where you set an variable to an array of different settings and the header file then acts according the $headerArgs array, thus making the header file dynamic enough to make specific changes for each page.
So I'm wondering how have you templated the sites you've built sites. My solution is to create a /blocks/ directory that contains an assortment of files like header.php and foother.php. Also it could contain other blocks such as php code blocks for session handling or whatever you wish. The only problem I'm having with this way of doing things is I don't know if I would want to make the header file a block that goes into the top of the body of every html page, or if I want to make it the top of every page (that is, include the doctype, head tag, etc.). Or maybe I could make another file for php at the top of every page called "preout.php" which basically means php code that is executed before any output is sent back to the browser.
I also thought I'd post this just to through what I'm doing out there for constructive criticism. Please leave a comment or add a suggestion.
So I'm wondering how have you templated the sites you've built sites. My solution is to create a /blocks/ directory that contains an assortment of files like header.php and foother.php. Also it could contain other blocks such as php code blocks for session handling or whatever you wish. The only problem I'm having with this way of doing things is I don't know if I would want to make the header file a block that goes into the top of the body of every html page, or if I want to make it the top of every page (that is, include the doctype, head tag, etc.). Or maybe I could make another file for php at the top of every page called "preout.php" which basically means php code that is executed before any output is sent back to the browser.
I also thought I'd post this just to through what I'm doing out there for constructive criticism. Please leave a comment or add a suggestion.