templates + includes = efficiency
Updating or just maintaining a website can be a daunting task, encouraging procrastination in the most seasoned designer. To combat this dilemma, I’ve implemented a combination of HTML templates and PHP includes to significantly accelerate website change. Although not applicable to every site, these pieces of web pages can usually be siphoned off into include files:
- Headers or banners
- Menu or links bar
- Sidebar (if not included above)
- Footer
To create include files, I simply put the code required for each piece in its own file with a .inc extension (i.e. header.inc). To link to it in the base document, add this line – <?php include(“file.inc”); ?> – where the code in file.inc would normally be. Assuming you’ve inserted the correct information between the quotes, your code in the include file will appear in place of the php line (view source code to see this, or to see the error generated if you’re having problems).
The benefits of includes…heheh…include the ability to update many files with one physical change, and also that you don’t have to update and re-upload all of your files attached to a template. Simply re-upload your include file and all changes nicely.
I take this simple include idea a step further by inserting these into templates rather than individual HTML files. That way I can increase my coding efficiency and minimize errors (and thus time spent fixing errors). I’m all about efficiency, so ideas like these just tickle me pink.
Add comment September 17th, 2006






