PHP Templating
PHP Website Templating Engine
- Project Goals
- Create a simple PHP-based templating system which mimics/approximates
Mason's inherent content-wrapping templating functionality for my personal
website (this website).
- Skills used
- PHP, HTML, CSS
- Details
- One of the aspects of Mason that I really enjoy as a web-scripting
language is its built-in template-system functionality: put an
autohandler file in your web-root directory with whatever
header/footer/logic you want, and it gets applied to any/all pages in
your website *automagically*...this makes adding additional pages
quick-n-easy, since it allows you to focus on the content of the
page, not on headers/footers/navigation/etc. if you don't want to. I
did some research on the web for a PHP-based solution, and either
found entire CMS-like systems (e.g. PHP-Nuke)
which were utter overkill for my needs, or basic scripts which dynamically
included a specific content file into a webpage template via a querystring parameter
or similar -- this was non-ideal
for my needs. I also wanted something more sophisticated than simple file-includes
for the header and footer within each PHP page!
Then I found stargeek.com's simple template structure
which, with a little tweaking, seemed like just what I needed.
Additionally, I wanted to try out the new CSS 2.0 table-less "liquid" layout
as explained at
Floatutorial,
so I integrated that layout into the template system design.
- Examples/Links
- yojimg.net (this website)
-
http://www.yojimg.net/bike/cyclotouring/ (page using LHS nav template)
-
http://www.yojimg.net/bike/cyclotouring/ride_reports/2005.07.24/ (page using nav-less template)
- Selected Source Code
- Page Class/Main Template Engine
- Standard Layout Template
- Alternate Layout Template
- Dynamic Breadcrumb Header