This is why I was wondering if there was a htaccess or similar something I could do so I wouldn't have to put all that code on each page.
This is why we seperate content, logic, and design. I like to do something like this:
Code:
<?php
session_start();
define('BASE_PATH', 'http://80.4.194.222/tcc/');
require_once("includes/functions.inc.php");
ob_start();
require_once("includes/header.inc.php");
$header = ob_get_clean();
$parm = "";
$conn = mysql_pconnect("localhost", "twey_tcc", "dbaccess14*");
mysql_select_db("twey_tcc");
// module-selection stuff, removed for brevity
ob_start();
require_once("includes/sidebar.inc.php");
$footer = ob_get_clean();
ob_start();
require_once("includes/footer.inc.php");
$footer = ob_get_clean();
if(!isset($forum)) require("includes/template.inc.php");
?>
That's an example directly lifted from the site I've been working on, so it's got more cruft than is strictly necessary, but you get the idea. template.inc.php simply contains:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
Copyleft: Any portion of this site may be copied, modified, or redistributed, for free or for profit, by any means possible, with the stipulations that:
a) credit is given to me, Twey, the author;
b) this license also applies to any derivative works.
-->
<html>
<head>
<title>
twey.co.uk :: <?php echo($cat); ?> :: <?php echo($title); ?>
</title>
<link rel="stylesheet" type="text/css" href="style.css.php">
<!--[if IE]><link rel="stylesheet" type="text/css" href="iehacks.css.php"><![endif]-->
</head>
<body>
<div id="corner">
<p id="logocontainer">
<a href="#content"><img src="images/invisible.gif" alt="Skip to content" style="border: 0 none;"></a>
<img src="images/logo.png" id="logo" alt="Twey's Logo">
</p>
</div>
<div id="header">
<?php echo($header); ?>
</div>
<div id="sidebar">
<?php echo($sidebar); ?>
</div>
<div id="content">
<h2><a href="?q=catdisp&c=<?php echo($catrow['id']); ?>"><?php echo($cat); ?></a><span style="font-size: 150%;"> :: </span><?php echo($title); ?> ( <?php echo($parm); ?> ) ;</h2>
<?php echo($content); ?>
</div>
<div id="footer">
<?php echo($footer); ?>
</div>
</body>
</html>
Bookmarks