Playing with Technology

Any sufficiently advanced technology is indistinguishable from magic. ~Arthur C. Clarke

Creating template based websites

I’ve been trying to develop a template based website design for the College the past couple of days. There are two problems to overcome: the current server does not support server-side-includes and the personal pages server doesn’t allow PHP. The natural way to create a template based site is to create headers, footers, and other common elements and include them with an include statement, this requires server-side-includes. The requirement for server-side-includes can be overcome by using PHP and require() statements, but of course this requires PHP to be enabled. So the bottom line is that I have a template for sites residing on the main web server, but there is no workaround I can see for sites living on the personal pages server.

In the process of trying to overcome the limitations of the configurations of the servers, I came across a solution to another problem. I like to have my web pages show the date and time of last modification. On my test server this was an easy echo in PHP of some server variable, but safe mode or some other restriction on the Netware Apache renders this inoperable. So I have found that the following will work instead:

*****************
**Get environment variables.
******************
$full_path = getenv("REQUEST_URI");
*****************
** Evaluate base path's existence,
** get filename and compensate for
** hidden index.html file then return
** date and time of last modification.
*****************
$dot_pos = strpos($full_path, ".");
if ($dot_pos == false) {
$base = $full_path;
$page_file = "index.php";
} else {
$base = dirname($full_path);
$page_file = basename($full_path);
}
echo "Last modified: " .date('F d, Y ', filemtime($page_file));
echo "at " .date('h:i:s A.',filemtime($page_file));

Make sure to enclose this in a PHP environment and that pages including this code fragment end in .php. Enjoy.


Posted

in

by

Tags: