Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>My page</title>
<link rel="STYLESHEET" type="text/css" href="/style.css"/>
</head>
<body>
<?php
include "common/include/banner.php";
include "common/include/leftMenu.php";
include "common/include/rightMenu.php";
?>
<div id="body">
blah blah blah
</div>
</body>
</html>I thought of putting all that header stuff (ie. everything before the body div) into another include file and having each page include that, but this will only work if every page had the same banner/leftMenu/rightMenu. For me, the commonality is in the layout - not in the specific contained components.
Struts (a Java framework) has a neat extension called Tiles that helps manage this very problem... has anyone seen a similar technique for PHP? I've been thinking about developing a Struts-like library something along the lines of:
Code: Select all
<?php
require_once "myGroovyStrutsLookalike.php";
startPage("/layout.php");
setComponent("banner", "common/include/banner.php");
setComponent("left", "common/include/leftMenu.php");
setComponent("right", "common/include/rightMenu.php");
?>
<div id="body">
blah blah blah
</div>
<?php
endPage();
?>--
Edwardaux