N E T B U I E dot net
The other white meat

June 28, 2005

Sloppy HTML Pt. II

I spent some time trying to untangle the mess, and actually made some progress.

The housekeeping tasks are:

  • Write php for images to use a template page
  • Write php for site pages to use a template page
  • Clean up the CSS and stylesheets
  • Finish photoblog
  • Write up stuff for archive pages

The original random image generator used whatever images were in the photos directory on my site. This created two problems: first, all images in that directory were duplicated elsewhere, resulting in wasted space on the webserver; second, the thumbnails for the images were linked only to the large images alone, rather than to a larger image contained within some sort of template page that looked like the rest of my site.

I handled the image issues by having a text file with one line for each image in the rotation, for example:

<a href="photos_nc.php?image=02pb10"><img src="tnails/02pb10-sm.jpg" class="littlepic" /></a>

Instead of copying the jpegs into a photos directory, I'm just pointing to my Gallery albums directly. There is a separate template page for each album, and a php variable is set to the individual filename by clicking on the thumbnail itself.

There is a line in each template page that places the correct image in the middle of the page:

<img src=albums/central-NC/<?php echo($image) ; ?>_lg.jpg class="mainpic">

Because Gallery creates separate directories for each album, I took the path of least resistance and creates separate php templates for each album. I was still able to save several 10s of mb by deleting all the duplicate images.

I used the same technique to create a template for all the other sub-pages on my site. There is one template, or skeleton, page that contains all the stuff I want all my pages to have (menubar, links, copyright statement, etc), plus the following line:

<?php @ require_once ("$page"); ?>

Any time someone clicks a link, say to the Photos page, the link points to the template page, and the variable gets set to the correct *.txt file, and the above code places that *.txt file in right spot.

All the links have been updated, so instead of a link to

<a href="about.html">

there's a link to

<a href="skel.php?page=about.txt">

There's a single template to modify now, and a whole bunch of plain text files that get loaded into that template when someone clicks on the appropriate link. Much simpler to maintain.

The last thing I had to do was put a redirect at the top of all the original html pages like so:

<?php header("location: ../skel.php?page=about.txt"); ?>

So, I still have a bazillion html files, but they all redirect to the new php-based pages. When I decide to rework my page design, I'll only have to modify the single template page.

A note on the php redirect, that line has to go at the very top of the html file for it to work.

I still have to work on tidying up the CSS, as some pages look fine and others look... not so fine. And I have to write the Movable Type archive pages.

But, I finished the photoblog, so that's done. Now if I could only get some people to come look at my pictures...

Posted by jbuie at June 28, 2005 11:03 AM
Comments