Random Photo Module for Gallery
It took a while to get the Gallery random photo block to work properly with PhpNuke. Most of the solutions are in the Gallery forums… if you look carefully. Heres how I did it… The first error (and also the most commonly asked question on the forum) has to do with the rand() function. The error displayed is:
Warning: rand() expects parameter 2 to be long, string given in /home/victorf/public_html/modules/gallery/block-random.php on line 138
$count contains a space so its being treated as a string instead of a number. To fix it I just added 0 to it in function choosePhoto()
$count = $cache[$album->fields["name"]] + 0;
Next problem seemed to be in sessions.php. Efarmboys post pointed me in the right direction. Adding the following lines near the top of randompic solves the problem:
global $GALLERY_NO_SESSIONS ; $GALLERY_NO_SESSIONS = 1; global $GALLERY_EMBEDDED_INSIDE; $GALLERY_EMBEDDED_INSIDE="nuke";
I added Gallery_Embedded_Inside while I was at it so that clicking the thumbnailopens the embedded version of Gallery.
The last problem I had was that the photo was being displayed above the block frame. Seems the code was printing the output instead of setting a string called $content as PhpNuke requires. I just changed all the echo’s. Not sure if this will work for other CMS though.
$content .= "$caption";
Joerg has a nifty new version of Random Block that lets you edit the thumbnail image size and a few other parameters, its for PostNuke.
Also HalfDead has a alternative method of displaying a random picture. I havent tried it, but it looks simple and efficient.