I need help making a template

<?php
   require '../../HordeAutoLoader.php';
   require '../settings/domain.php';
   require '../head/head.php';
   require '../nav/nav.php';
   require '../nav/leftnav.php';
   require '../toolbar/toolbar.php';
   require '../hd/hd.php';

?>

<head>
<?php echo $head; ?>
</head>
<body class="yui-skin-sam">
<div id="doc4" class="yui-t2">
   <div id="hd" role="banner">
<?php echo $hd; ?>
   </div>
   <div id="bd" role="main">
	<div id="yui-main">
	<div class="yui-b"><div role="main" class="yui-g">
	<!-- YOUR DATA GOES HERE -->
<?php echo $body; ?>
	</div>
</div>
</div>
	<div id="nav" class="yui-b"><!-- YOUR NAVIGATION GOES HERE --><?php echo $nav; echo $leftnav; ?></div>

	</div>
   <div id="ft" role="contentinfo"><p>Footer</p></div>
</div>

<!--Toolbar -->
<div class="toolbar">
   <?php echo $toolbar; ?>
</div>
</body>
</html>

Above is an example of a template I have.

Parts of my site have markup unique to just one page. It would be easier to just program the unique content in a separate .php file, than put the unique content in a database. However, if I put that content in a separate .php file, I’m not quite sure about how to put together the template. I was thinking something like

$body = <<<HTML
Your html here
HTML;

include(template.php);

and then template.php just echoes out the body?

Please direct me into the most efficient direction.

The unique content I’m speaking of, is just stuff that would be a pain to put in a database. For example, some topics have pictures other don’t. Some have multiple pictures, some don’t. Some topics have all kinds of caveats. There is just no standard way to deal with these things. They are unique.

You might want to consider using MODx instead of raw PHP. MODx is part CMS, part PHP framework. Your template would look like this:


<head>
[[*head]]
</head>

<body class="yui-skin-sam">

<div id="doc4" class="yui-t2">

<div id="hd" role="banner">
[[*hd]]
</div>

<div id="bd" role="main">

<div id="yui-main">

<div class="yui-b"><div role="main" class="yui-g">

[[*content]]

</div>

etc, etc....


Those fields between the braces are template variables and document fields which you or a client can fill out in the easy-to-use MODx interface.

Space doesn’t permit me to go into all the benefits of MODx here; suffice it to say that our team tussled with raw PHP files and templates for a couple of projects, then made the switch. It is so much easier and cleaner!