WITHIN TEMPLATE DOCUMENT:
<?php $x=head;
if (empty($url)){include('home/index.php');}
elseif (file_exists("{$url}.php")) {include("{$url}.php");}
else {include('errors/404.php');}
?>
<title><?=$TITLE; ?></title>
<meta name="description" content="<?=$DESC; ?>" />
<meta name="keywords" content="<?=$KEY; ?>" />?>
header, nav html here
<?php $x=body;
if (empty($url)){include('home/index.php');}
elseif (file_exists("{$url}.php")) {include("{$url}.php");}
else {include('errors/404.php');}
?>
footer html here
WITHIN INCLUDE DOCUMENT:
<?php if ($x==head) {
$TITLE = ''page title";
$DESC = 'meta page description';
$KEY = 'meta keywords;
return;}
?>
<div>This page is about stuff.</div>
The first sample (template) calls the include document for the header info. Upon encountering the return; it continues thru the template until it encouters the second include. The second include calls the same page, but because of the $head and $main variables, this time only includes the content.
I know one way of solving the problem is to include the header content in a seperate header.php file, but that would require two files for every page which I am trying to avoid if possible. BTW, I'm sure the second include could be simplified but it doesn't seem to work if I just say include $url.
The reason I chose not to do it the way 'whoisKeel' suggests is because upon loading any include document the page "flashes" or appears to reload as the header, nav, and footer are recalled. My way doesn't cause the static items to "flash" or appear to reload at all. Very anal I know, but if I like it that way if possible.
I would like to maintain the main template idea calling the includes pages, but I am willing to change anything else.