ZenphotoCMS Forum
Get Random Images from specific album - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Get Random Images from specific album (/thread-9929.html)



Get Random Images from specific album - reneesanguinetti - 2012-05-03

Hello,
I have read through the forum to try to find the answer to my issue, but I can't seem to get it to work.
All I am trying to achieve is to get random images to be selected from one specific album.
The original code is this:

I changed it to this:

I am probably missing something very simple. Any suggestions would be appreciated. Thank-you!

Zenphoto version 1.4.2.3 [9980] (Official Build)
Current gallery theme: zpFocus_ v1.4.2.2




Get Random Images from specific album - acrylian - 2012-05-03

Parameters look good so far. What is the probably actually? Nothing shows up? Error, if which?




Get Random Images from specific album - reneesanguinetti - 2012-05-03

No errors posted and the page shows up, but the random images still are drawn from all albums. Just as if I changed nothing.




Get Random Images from specific album - acrylian - 2012-05-03

If you read the doc of that function it says "rootAlbum" which means it includes all sub albums, too.

Note that in the 1.4.3 dev the image_album_statistics plugin's function getImageStatistic() has also a random image function. This at least can get random images from just one album. See the documentation in the file itself.




Get Random Images from specific album - reneesanguinetti - 2012-05-03

Hello,
I only have top level albums (2), no sub-albums. I even cleared the albums cache. Is there another function to get a specific album?
Thank-you.




Get Random Images from specific album - acrylian - 2012-05-03

I am not sure what you mean. You need to tell the function what album to use. So you need to know it. Have you checked what album you actually get on the page you trying to use this? What exactly is this supposed to do? $ssalbum = $_zp_current_album->getFolder()=='appliances';




Get Random Images from specific album - reneesanguinetti - 2012-05-03

I have test albums (top level) called appliances and another called baby products. Using $ssalbum = $_zp_current_album->getFolder()=='appliances'; I want the random images to come from the appliances album only.
This is what the page source shows:

[list]
[*]

[*]

[*]

[*]

[*]

[/list]
These are the albums shown on the gallery page:

[list]

                    Appliances



                    Apr 20, 2012



                        tes test test                           »





                    Baby Products



                    Dec 19, 2010



                        test test test                          »

[/list]




Get Random Images from specific album - acrylian - 2012-05-03

Your code is not properly escaped (use backticks!). If you want to have only and always the album "appliance" why do you have $_zp_current_album->getFolder() in there?




Get Random Images from specific album - reneesanguinetti - 2012-05-03

When I tried to find the solution on the forum this is the code that I thought would work '$_zp_current_album->getFolder()=='name';'. "name" being album name. How should I tell the function what album to use?
Thank-you.




Get Random Images from specific album - reneesanguinetti - 2012-05-03

Hello,
I think I have figured out the answer to my question.
I changed the code to this:
'

                '

Seems to work. Thank-you for your time!




Get Random Images from specific album - acrylian - 2012-05-04

Quote:$_zp_current_album->getFolder()=='name
Ahm, just to follow up that is wrong syntax. $_zp_current_album->getFolder() gets the name of the current album as the folder is the name (actual the path incl. parents toplevelfolder/sublevelfolder/...). This is the same as the object variable call $_zp_current_album->name.

So your change is exactly what you wish to do.