Untested but I would do something like this for flexibility and ease of expansion.
PHP Code:
<?php
/*
* 1.) Default mode
* 2.) Error mode
* 3.) $_GET mode key
*/
$default_mode = 'home';
$error_mode = 'error';
$mode_flag = 'mode';
/*
* Route configuration
*/
$routes = array(
'home'=>array(
'body_id'=>'home'
,'blurb'=>'home.html.php'
)
,'about'=>array(
'body_id'=>'about'
,'blurb'=>'about.html.php'
)
,'contact'=>array(
'body_id'=>'contact'
,'blurb'=>'contact.html.php'
)
,'error'=>array(
'body_id'=>'error'
,'blurb'=>'error.html.php'
)
);
/*
* Get requested route from mode
*/
$route = isset($_GET[$mode_flag])?array_key_exists($_GET[$mode_flag],$routes)?:$routes[$_GET[$mod_flag]]:$routes[$error_mode]:$routes[$default_mode];
/*
* Set-up template data
*/
$header = 'header.inc.html.php';
$nav = 'nav.inc.html.php';
$blurb = $route['blurb'];
$footer = 'footer.inc.html.php';
/*
* Dump template
*/
include($header);
include($nav);
include($blurb);
include($footer);
?>
In every one of those route arrays you can now define data that changes but is present on every page such as; the title,body id, etc etc w/o it being bound to the mode name. You can also build your navigation dynamically using the route configuration. Meaning if you ever need to add a page you won't have to touch the template code just the route configuration.
Bookmarks