|
|
How my php framework worksFirst off, some of this is ugly. I'm learning php, so I wouldn't say "I know php" yet. Secondly, I haven't figured out a nice way of doing some stuff yet. There may not even be a nice way of doing some of what I want to do. A page template:Each page is based on this template, which includes separate files for header, sidebar and footer. This is because these elements majorly define the look and feel of the website. The bulletttitle parameter is one which I have used to define the text which should be placed in the sidebar as a description of the page being linked to. The header code:<BODY TEXT="#000000" LINK="#400080" VLINK="#C40000" ALINK="#0000ff" background="bg.jpg"> <table width=100% cellpadding=0 cellspacing=0 cellborder=0> <tr> <td height=100><img src="icon4.gif" ALT="LuaP logo"></td> <td background="banner.jpg"> </td> </tr>Nothing special there really. Just note that the page is one big table, and the header is two cells on the top row. The sidebar code:
<tr><td WIDTH=200 valign=top rowspan=2>
<!sidebar things go in here>
<?$path_parts = pathinfo($_SERVER["REQUEST_URI"]);?>
<?$dirs=`ls -t -1 -r *.php`;?>
<?$dirnames=split("\n", $dirs);?>
<?$size=count($dirnames);
for ($i=0; $i<=($size-2); $i++)
{
if(((strstr("$dirnames[$i]","index.php"))&&($path_parts["extension"]==""))||
(strstr(urldecode($_SERVER["REQUEST_URI"]),"/~luap/$dirnames[$i]"))){ ?>
<img src="ledon.gif" alt="" width=40 height=30>
<?}else{?>
<img src="ledoff.gif" alt="" width=40 height=30>
<?}?>
<a href="<?echo "$dirnames[$i]";?>">
<?system ("cat $dirnames[$i] | grep bullettitle | awk -F \\\" '{print $2}'");?></a>
<br>
<?}?>
</td>
<td width=2000>
<!******************************
**** Page body starts here *****
*******************************>
The sidebar finds all files in the current directory which end in .php, and lists them in date order (this is driving me batty at the
moment, every time I make a new file, I have to touch all the other files... I need to ls -1 -t -r to reverse the order, then the
newest files will be last in the list.) Having stored this listing in a variable, it manipulates that slightly, and for each
filename, tests it against the request URI to determine whether to display an illuminated LED picture or a dark LED. It creates
a hyperlink to the filename, and displays the text from bullettitle as the visible link.
The footer code:
</td>
</tr>
<tr>
<td>
<!put footer things in here>
<hr color="#000000">
<p style="font-size:80%">
This page has been created by, and is maintained by Paul Norton.
All content is Copyright Paul Norton 2002/2003 unless otherwise stated.<br>
Comments, questions, notices etc should be sent to:
<a href="mailto:luap@icculus.org">luap@icculus.org</a><br>
<?echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());?>
(Timezone: America/New York)
</td>
</tr>
</table>
</body>
</html>
The only remarkable thing about the footer really is the last modified date. This returns automatically the last modified date of
the requested page. Last modified dates are a good thing for determining the accuracy and current-ness of the information you're
reading. What really infuriates me though is people who include a last modified date in their htm files, and then don't bother
to edit it when they actually update the page. Giving me wrong information is worse than not giving me any information at all.
I've been guilty of that one in the past.
|
|
This page has been created by, and is maintained by Paul Norton.
All content is Copyright Paul Norton 2002/2003 unless otherwise stated. |