Skip to navigation

malevolent design weblog

This blog is now defunct, but you can find more stuff over at my personal site

Similar Templating

Dave Shea’s approach to building up pages is a lot like my “Tesco Value” templating system used for small sites, although I tend to opt for functions rather than multiple includes to improve security and performance (several commenters made similar suggestions).

For example, a simple page might use a bit of PHP:


$section = 'services';   //site section the page is in
$title = 'Example Page'; //main bit of page title
$style = 'subpage';      //class to add to body tag

$description = 'An amazing example page.';
$keywords = 'template,php,hacky';


<p>Page content</p>


The functions use the global variables to build up the layout, highlight the current section in the navigation, etc., with a few simple if statements. For larger sites you need to look at things like XSLT and Smarty, but don’t feel compelled to overcomplicate.


Comments are now closed for this entry.