A while back, as some of you might remember, I tried getting phpBB to work. It failed.
Anyways, recently I have been appointed by my school's Robotics Team to build a website. Remembering my experiences with trying to get phpBB to work, and realizing subsequently that I don't even like the layout, I set out to design my own. The result: Fully functional pages that are only about 7 lines long.
All of the major utility functions are segregated to a "scripts.php" file, which is included in all main pages. An example page would be:
And that is all you need. The functions writeHead, writeTitle, loadPageContent, and finishPage are all contained in scripts.php. The loadPageContent function looks like this:PHP Code:<?php
include("scripts.php");
writeHead();
writeTitle("Lakeview Legends - Index Page");
loadPageContent("index.txt");
finishPage();
?>
I also have a nifty function for embedding a Flash control in PHP without having to rewrite the Flash control every time you make a new one.PHP Code:function loadPageContent($contentFile)
{
if (!file_exists($contentFile))
{
echo('File not found: $contentFile');
return;
}
if ($file = fopen($contentFile, "r"))
{
while(!feof($file))
{
$line = fgets($file);
echo($line);
}
}
}
Also, here's the writeHead and writeTitle functions.PHP Code:function echoFlashControl($flash, $altFile, $width, $height)
{
if (!file_exists($flash))
{
if (file_exists($altFile))
{
if ($file = fopen($altFile))
{
while(!feof($file))
{
$line = fgets($file);
echo($line);
}
}
fclose($file);
}
else
{
echo('ERROR');
return;
}
}
else
{
echo('<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="$width" height="$height" />' .
'\n<param name="movie" value="$flash" />\n<param name="quality" value="high">\n<embed src="$flash" quality="high" ' .
'pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="$width" height="$height" /></embed>\n<noembed>');
if (file_exists($altFile))
{
if ($file = fopen($altFile))
{
while(!feof($file))
{
$line = fgets($file);
echo($line);
}
}
fclose($file);
}
echo('</noembed></object>');
}
return true;
}
It's not much in the way of revolution, but if XHTML can be standardized and simplified, then so can PHP.PHP Code:function writeHead( )
{
echo( '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' .
'<link rel="stylesheet" type="text/css" href="style.css" />\n' .
'<html xmlns="http://www.w3.org/1999/xhtml">\n' .
'<head>\n' .
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n' .
'<!-- Begin writing of PHP scripts here -->\n');
}
function writeTitle($content)
{
echo('<title>$content</title></head>\n<body>\n<div class="content">\n');
}



Reply With Quote


Bookmarks