Approximating Master Pages in PHP

master.php

<html>
<head>
<title><?php echo $pagetitle; ?></title>
</head>
<body style="margin-top:20px;margin-left:20px;margin-right:20px;">
<table width="100%" border="0" cellpadding="10" cellspacing="0"border="0">
<tr bgcolor="#33FFFF">
<td colspan="5"><h2>Template Specific Header</h2></td>
</tr>
<tr bgcolor="#EEEEEE">
<td nowrap><a href=#">Navigation Link 1</a></td>
<td nowrap><a href="#">Navigation Link 2</a></td>
<td nowrap><a href="#">Navigation Link 3</a></td>
<td nowrap><a href="#">Navigation Link 4</a></td>
<td width="100%">&nbsp;</td>
</tr>
</table>
<table width="100%" cellpadding="10" cellspacing="0" border="0">
<tr>
<td width="30%" valign="top" bgcolor="#EEEEEE"><strong>Template Specific
Navigation</strong>
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</td>
<td width="70%" valign="top"><?php
echo $pagemaincontent;
?></td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="10" border="0">
<tr>
<td colspan="2" bgcolor="#33FFFF">Template Specific Footer</td>
</tr>
</table>
</body>
</html>
index.php
<?php
  //Buffer larger content areas like the main page content
  ob_start();
?>
<em>Page Specific Content Text</em>
  Lorem ipsum dolor sit amet, consectetuer adipiscing
  elit, sed nonummy nibh euismod tincidunt ut laoreet
  dolore magna aliat volutpat. Ut wisi enim ad minim
  veniam, quis nostrud exercita ullamcorper
  suscipit lobortis nisl ut aliquip ex consequat.
  Duis autem vel eum iriure dolor in hendrerit in
  vulputate velit molestie consequat, vel illum
  dolore eu feugiat nulla facilisis ats eros et
  accumsan et iusto odio dignissim qui blandit
  prasent up zzril delenit augue duis dolore te
  feugait nulla facilisi. Lorem euismod tincidunt
  erat volutpat.
<?php
  //Assign all Page Specific variables
  $pagemaincontent = ob_get_contents();
  ob_end_clean();
  $pagetitle = "Page Specific Title Text";
  //Apply the template
  include("master.php");
?>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: