Pages (2): 1 2   
Administrator
Administrator
fretzl   2012-02-12, 19:38
#1

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 :-(

Administrator
Administrator
acrylian   2012-02-12, 19:49
#2

Sure the value get from getCodeblock is correct?

Administrator
Administrator
fretzl   2012-02-12, 19:54
#3

Let's say the input in the codeblock is for example [i]testalbum[/i]
If I echo $albumname; I also get [i]testalbum[/i]

Administrator
Administrator
acrylian   2012-02-12, 20:04
#4

That's weird then and does not really make sense... No idea right now, that should actually work..

Member
Member
sbillard   2012-02-13, 04:34
#5

You should have got an error if the album was not created. Did it provide any clues?

Did you look at the page html of the echo? You cannot really trust what the browser shows, there might be markup or such included.

Administrator
Administrator
fretzl   2012-02-13, 07:20
#6

The posted code does work (without errors) but it shows random images from the entire gallery.
Of course I should have mentioned this, sorry.

Only if I hardcode an [i]albumname[/i] does it show random images from that specific album.

Administrator
Administrator
acrylian   2012-02-13, 11:15
#7

Hm, for the function it is really meaningless where the value comes from. I will try later as well. Before that, just to be sure you are not confusing yourself: the option defines the root album so that means all sub albums are used as well.

Administrator
Administrator
fretzl   2012-02-13, 12:12
#8

Thanks.
There are no subalbums.

Administrator
Administrator
acrylian   2012-02-13, 12:51
#9

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.

Administrator
Administrator
fretzl   2012-02-13, 13:06
#10

Much appreciated!

I'll investigate further.

Member
Member
sbillard   2012-02-13, 19:18
#11

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.

Administrator
Administrator
fretzl   2012-02-13, 22:04
#12

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.

Member
Member
sbillard   2012-02-13, 22:14
#13

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.

Administrator
Administrator
fretzl   2012-02-13, 22:49
#14

Well, the first test allready failed.

$albumname = getCodeblock(2,$_zp_current_zenpage_page); if($albumname=="testalbum") echo "OK";
does not output OK.

EDIT: That is on the PC with the Nightly Trunk

Member
Member
sbillard   2012-02-14, 00:26
#15

So the codeblock does not contain the string "testablum". Try echo html_encode($albumname); and see what is really there.

Administrator
Administrator
fretzl   2012-02-14, 07:33
#16

echo html_encode($albumname); outputs [i]testalbum[/i]

Administrator
Administrator
acrylian   2012-02-14, 11:04
#17

That's weird, why does it work for me out of the box?

Member
Member
sbillard   2012-02-14, 21:43
#18

Well, there seems some difference otherwise the equal test would come up true. As to what, I really do not know. But if $albumname is really not equal to "testalbum" then that does explain why the rest does not work.

Administrator
Administrator
fretzl   2012-02-16, 07:23
#19

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 ??

Administrator
Administrator
acrylian   2012-02-16, 14:29
#20

Maybe funny cache tricks again?

Yes, if you don't set a root album it uses the whole gallery. We once had a php issue with NULL vs empty, so on some servers it triggered wrong somehow.

Try adding a check if the code block is empty so it is not used.

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.