
Originally Posted by
felgall
The other server side alternative is to use a programming language that generates the HTML for each page and which allows for a lot of other things as well as being able to share common HTML.
Which is the approach I'd suggest you learn... using PHP since it's the most commonly available on servers.
Let's just say you have everythign before your unique content in header.php
header.php:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
lang="en"
xml:lang="en"
><head>
<meta
http-equiv="Content-Type"
content="text/html; charset=utf-8"
/>
<meta
http-equiv="Content-Language"
content="en"
/>
<link
type="text/css"
rel="stylesheet"
href="screen.css"
media="screen,projection,tv"
/>
<title>
<?php
echo isset($pageName) ? $pageName.' - ' : ''
?>
Site Name
</title>
</head><body>
<div id="pageWrapper">
<h1>
Site Name
<span><!-- image replacement --></span>
</h1>
<ul id="mainMenu">
<li><a href="#">Home</a></li>
<li><a href="#">Forums</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div id="contentWrapper"><div id=content">
and everything after your unique content in a footer.php
footer.php
Code:
<!-- #content, #contentWrapper --></div></div>
<div id="sideBar">
SideBar Content Here
<!-- #sideBar --></div>
<div id="footer">
© Whoever, All rights reserved.
<!-- #footer --></div>
<!-- #pageWrapper --></div>
</body></html>
Each of your unique pages would then be built using php thus:
Code:
<?php
$pageName='Unique Page Name';
include('header.php');
?>
<h2>Unique Page</h2>
<p>
Unique page content here
</p>
<?php
include('footer.php');
?>
That's the simple way. I would actually probably use functions for the header and footer using echo statements, but I tend to pass more unique data to the page -- this was just a quick example. (Normally I don't advocate even using <?php ?> more than once in a file -- but this is likely simpler for you to follow just starting out)
I threw in the $pageName variable so you could start to see how those work as well. That way you can pass a unique TITLE tag to each sub-page. More advanced you could "trap" that variable when building the menu to highlight the current page.
Bookmarks