On a Zenpage page I'm tying to get a random image from a specific album.
The name of the album/folder is put in a codeblock as plain text.
I then use the printCustomSizedImage() function to display the random image.
This is what I have so far:
$albumname = getCodeblock(2,$_zp_current_zenpage_page); $albumobj = new Album($_zp_gallery,$albumname); $randomImage = getRandomImagesAlbum($albumobj); makeImageCurrent($randomImage); printCustomSizedImage(NULL, NULL, 512, 546, ... etc);
The $albumobj is only created if I hardcode the albumname
(i.e. $albumobj = new Album($_zp_gallery,"");)
I just can't figure out what's wrong :-(
I just tried with trunk and Zenpage theme. I used a top-level album with 3 images and reloaded the page dozens of times. I always got only images from it. So I am sadly not able to reproduce it using the whole gallery as there are 8 albums and 3 dynamic ones additionally.
You did say that the album object was created only if you hardcoded then name. Is that the case, or is an object being created?
Similar question for the image object. Is one created?
My speculation is that the answere to both these is that the object is not created. If makeImageCurrent($image) is not passed an object it does nothing, so whatever $_zp_current_image was will not have been changed. Probably somewhere else this variable is being setup to some image from the album in general.
If change this:
$albumobj = new Album($_zp_gallery,$albumname);
to this:
$albumobj = new Album($_zp_gallery,"testalbum");
then it works.(i.e. only images from the specified album are shown)
I also checked if an albumobject and an imageobject were created by using:
if (is_object($albumobj)) echo "something";
and
if (is_object($_zp_current_image)) echo "something else";
They both were.
I now see different results on different installs:
On one PC it works with the SVN Development and SVN Trunk.
PHP version: 5.3.0 MySql version: 5.1.37
On another it does not work with the Nightly Trunk.
PHP version: 5.3.6 MySql version: 5.1.49
Note that "not working" means that images from the entire gallery are shown.
So, I guess the next test is as follows:
first make a test $albumname=="testalbum" just to be sure that they are not somehow different.
Then check to see if the two versions both fail on the PC that has the Nightly Trunk.
But I suspect so. If you are using todays' SVN Trunc and last night's Trunk nightly then there is only one change to the isImagePage() function. So it would not be Zenphoto code that makes the difference.
If I put the albumname in another codeblock it suddenly works!
The echoed checks are also correct.
I then put the albumname back in the original codeblock it also works.
Guess that must have been a very persistent browser cache.
Now this might be something:
If I leave all codeblocks empty it still shows random images of the entire gallery ??