![]() Photo Gallery | A self-indexing photo galleryThe following description still needs some work. It may not be easy to follow. It may be too simplistic for real geeks and over the head of ordinary mortals. But if you more or less know your way around HTML and PHP, it shouldn't be too difficult if you read slowly. Anyone who wants to clarify my obtuse writing style (and/or thought process) is more than welcome to drop me a note with suggested improvements. I reserve the right to ignore or mock them as I see fit.The big idea here is to create a web photo gallery that can process the pictures and text that you drop into folders and automatically write the html dynamically to reflect what's in the folders. Each folder and subfolder needs to contain the ubiquitous index file (index is actually index.php with .php lopped off); which just includes two files in core that should be placed in your site root directory. If core is not in your root, you'll need to rewrite the include statements in index (and the stylesheet reference in indexme.inc) to reference wherever you put core relative to root. In other words, as an absolute reference. This just makes things simpler, because then you can use the same index file for each folder in the gallery. The two include files that index references make the server build html from other items in the same folder as index; images, text, and subfolders. The doctype is specified in indexme.inc, so only one file needs to be updated if you want to change that. And styles are defined in an external stylesheet. First, this mechanism looks for a default text file which describes the contents of the folder. Your choices here are default.txt (for basic text with simple formatting) or html.txt (for more complicated html or custom styles). For more on this, see the default folder and html folder Then, it looks for images, and if it finds them it creates links to the images, but it uses itself as part of the url (i.e., http://yoursite.com/index/photo.jpg). The image appears within the index page where it replaces the default text, not as a separate link. In theory, this should help it be indexed by search engines, but I'm really not too sure that this works yet. Also, if it finds an image, it looks for a correspondingly named text file (image.txt for image.gif), and if found, places it beneath the image. Then, it looks for subfolders, and if it finds them, creates more links. These subfolders also need index files in them to repeat the trick. The whole point of this being that you can construct the pages without wasting a lot of time writing links and painstakingly coding every little thing. You still have to know how it works and what you're doing, but it cuts out a lot of the redundant and brain-numbing stuff. So if you want to put some more picture links on a page, you just dump some images in a folder. Job done, log off, crack a beer. You want to rename a folder? So rename it. You want to put a subfolder in a different directory? Drag and drop, buddy. All done with the magic of PHP. Since the original thought was "Personal Home Page", this seemed like a good use for it. The genesis for all of this was an article by Morbus Iff, in which he described a search-engine friendly image gallery. The idea was further enhanced by hacking off large chunks of Flinn Mueller's clever URHere script, which provides the string of "you are here" links at the top of the page. The only sneaky thing I've had to do is to add some .htaccess mangling so I could get rid of the php extension on index, and make the server look at them. The file only contains this: <Files index> ForceType application/x-httpd-php </Files> DirectoryIndex index index.html In theory, the extension extraction may help some search engines index the site better, but that may only be wishful thinking on my part. Also, it would probably make a hell of a lot of sense to call "index" something else, but I just stuck with the concept of what an index is supposed to do. Plus, I'm lazy. At the moment, this whole scheme seems to work with a plain vanilla Apache installation without any fancy stuff. And the output validates as XHTML 1.1 Strict. The links at the upper left were automatically generated by pictures and text files in the same folder as this file. If you click through the list, you'll learn a little more about this here idea. |