Since I just recently completed the website layout for my humor pages, I thought I'd share the steps I went through creating it. Some people prefer to use content management systems or weblogs, written by someone else, in order to concentrate on content. Before I created the website, I tested several scripts and determined they required too much editing and maintenance for what I wanted to do with the website. I wanted to keep it dynamic, yet simple, since I would be the only one adding content. I chose php for the scripting because it's available with almost every hosting plan in existence. Here then, is the step-by-step procedure I used:

1. I created a "contents.txt" file with the display and link contents for each menu link. Each line in the file is in the format of "Main Page|main" (without the quotation marks). I left out the extension because each page would end with the .php extension.

2. I created the index.php file which contains:

a. The php code to determine which page is being requested. The reason for the first header redirect is to prevent anyone from accessing a page without the query string at the end of the URL:

<?php
$p = $_GET['p'];
if (!isset($p)) {
header("Location: index.php?p=main");
exit;
}

b. The php code to establish the current URL, store the "contents.txt" file into two arrays, and to establish which heading (and page title) went with the current URL. The $linklist array is designed to work with the subdomain name as well as the subdirectory, depending on how the website is accessed. The reason for the second header redirect is to prevent anyone from entering anything arbritary for the query string. Of course, we wouldn't know what was arbitrary until the "contents" file was parsed:

$URL = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
$file = file("content.txt");
$file = str_replace("\n","",$file);
$file = str_replace("\r","",$file);
for ($i=0; $i
$line = $file[$i];
$part = explode("|", $line);
$displaylist[$i] = $part[0];
$plist[$i] = $part[1];
$linklist[$i] = "/index.php?p=".$part[1];
if (substr($_SERVER['PHP_SELF'],0,6) == "/humor") $linklist[$i] = "/humor/index.php?p=".$part[1];
if ($URL == $linklist[$i]) {
$heading = $displaylist[$i];
}
}
if (!in_array($p, $plist)) {
header("Location: index.php?p=main");
exit;
?>

c. The standard HTML heading of the page and the layout of the page, up to the point where the menu would be created by a loop. The menu loop:

<?php
for ($i=0; $i
echo " <a hef=\"$linklist[$i]\">$displaylist[$i]</a><br />\n";
}
?>

d. More of the page layout up to the point where the page is requested. I picked up the file last modified date at the same time (for the foot of the page):

<?php
$file = "pages/".$p;
$lastmod = date("Ymd", filemtime($file));
$page = file_get_contents("pages/".$p);
echo $page;
?>

e. The last part of the layout up to the php code at the foot of the page:

<?php
echo " Page last modified: $lastmod";
?>

3. I then created the style sheet, linked it to the index page, and went back and added all the CSS properties to the index page.

4. I copied the jokes and stuff to separate pages and inserted <div>, <p> and </p>, and <br /> tags where necessary. At this point, I must emphasize that only the text and the tags had to placed on individual pages. The index file takes care of the rest.

5. I tested the website on a web server on my own PC to make sure everything worked as intended before uploading it the host.

I probably made the entire procedure sound simple. It was, for me, but then I've been doing this kind of stuff for years. Of course, I've gone back in to the layout and CSS properties since I uploaded in order to tweak some things. Now when I add more pages, I just need to do what did in step 4, update the "contents.txt" file and upload them to the host.

I could have gone into much more detail about the php code, or even the layout, but each piece is a topic in itself. Anyway, I won't be surprised if I use the same code and layout on other websites. Why reinvent the wheel each time?