block-random-enhanced.php: An enhanced version of
Gallery 1.5's block-random.php
Jeff Barca-Hall
With the release of Gallery 1.4.4-RC1, the Gallery development team quietly(!) included, for the first time, an "official" version of block-random.php. Hooray!
That version, however, lacks some of the enhanced functionality that users of block-random variants have come to enjoy. For instance, the version that I have been supporting handles sub-albums, allows for customization with some optional parameters, and supports page integration using both server-side technologies such as PHP or SSI, as well as a client-side technique (IFrame plus JavaScript).
Note: this version has been developed and tested "standalone", not
in a CMS/portal environment. If you are running PHPNuke or PostNuke, check out
holzapfel-online.de or nukedgallery.net.
I have now merged my changes into the official block-random.php and introduce
them here, with a new file name:
Users of my earlier version of block-random.php should follow the notes for upgrading to this version, which requires Gallery 1.4.4 or later. If you are still on an older version of Gallery, my old block-random source is archived here with the filename block-random-pre144.phps.
What's enhanced about block-random-enhanced.php?
Example: The page you are currently viewing is an SSI page with two random blocks at the top, each placed in its own floating div. Here is the syntax used for each of them; if you View Source in your browser, you will see the result (look for the "Begin SSI call" comments):
<!--#include virtual="/gallery/block-random-enhanced.php" -->
<!--#include virtual="/gallery/block-random-enhanced.php?album=favorites" -->
<!--#include virtual="/gallery/block-random-enhanced.php?size=100&target=_blank" -->
Those of you who have been using my custom version of block-random.php today
(July 2004) are probably using an IFrame and client-side inclusion (the browser,
rather than the server, makes the call to get the random photo). That was the
technique I used and documented.
However, in moving my site to a new host recently, I decided to switch to server-side
inclusion for my random photo block, using the SSI (Server-Side Include) feature
of most web servers. This has advantages over the IFrame technique, such as
smoother page layout (no resize after page load), and a simpler implementation
in your page (no IFrame, no JavaScript). I encourage those of you using IFrames
to give
SSI a try, even if it means having to rename your page extension to .shtml
(not necessary for me, though; my hosting provider uses CPanel, and I was able
to configure Apache to server-parse .html files, too).
For those of you who prefer not to, or who can not use server-side includes, my documentation on client-side IFrame usage still applies.
If you are already using a modified block-random.php from this site, and you just want the latest version with as little effort as possible, then follow these instructions. This is also the way to recover if your Random Photos stopped working correctly after you installed a new version of Gallery:
iframe src="/gallery/block-random.php?size=125&target=_top&album=tristan5"
then you should now use:
iframe src="/gallery/block-random-enhanced.php?size=125&target=_top&album=tristan5&body=1"