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:
<?
require_once($_SERVER['DOCUMENT_ROOT'].'/somewhere/something.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
//metadata
$description = 'An amazing example page.';
$keywords = 'template,php,hacky';
pageStart();
?>
<p>Page content</p>
<?
pageEnd();
?>
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.
Wed 15th Jun 2005, 8:55pm GMT
Filed under: Hints and Tips, Server-side Coding, Web
Comments
Comments are now closed for this entry.
Matt Round’s company blog, covering web development, media, technology and pretty much anything else.
- Web Sites
- Good-looking, effective, accessible sites.
- Multimedia
- Logos, Flash games, animation and illustration.
- Advice
- Help with strategy, planning and getting noticed.
