GetSimple Support Forum

Full Version: [Solved] Need some help with displaying a random thumbnail from 2+ galleries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I use the following code to display a random thumbnail to my website.
PHP Code:
<?php get_i18n_gallery('gallery1',array('url'=>'gallery1''thumb'=>'random')); ?>
This code selects a random picture from my gallery1 and display the thumbnail.
I want to select random pictures from 2 or more galleries and to display the random thumbnail.
How can I integrate gallery2, gallery3... in this query?
I tried with array but didn't succeed, maybe I didn't make the correct array code. Any suggestion?
Thanks
(2013-03-13, 00:59:08)Alb Wrote: [ -> ]I use the following code to display a random thumbnail to my website.
...
How can I integrate gallery2, gallery3... in this query?

It's not possible.
You could pick the gallery at random also.

PHP Code:
$gallery 'gallery'.rand(1,3);
get_i18n_gallery($gallery,array('url'=>$gallery'thumb'=>'random')); 
Thank you for your replies. I succeed to make it work. My galleries has different names like what I write in the first post. They are not gallery1,gallery2,gallery3....
they are my-first-gallery, another-gallery-name, etc...
I use this code to switch them:
PHP Code:
<?php
 $gallery 
Rand (1,2); 
switch (
$gallery) {
 case 
1:
 
get_i18n_gallery('my-first-gallery',array('url'=>'my-first-gallery''thumb'=>'random'));
 break;
 case 
2:
get_i18n_gallery('another-gallery-name',array('url'=>'another-gallery-name''thumb'=>'random'));
 break;  } 
 
?>
And in case I want to add another gallery I should add another case and edit the rand() max.
You think is ok this code? As long as it works I think is good, but better double check if can be a bug or something .
Thanks
Then you just stick the names in an array and use the rand as the index when fetching it.
Ill post code later if you can't figure it out
(2013-03-18, 03:04:44)shawn_a Wrote: [ -> ]Ill post code later if you can't figure it out
It works for me the way I did. I don't want to make things complicated. I understand the way the code works and I know what to add/delete in case I want to make changes to the gallery.
Maybe you have a simple version but if it works like this, I just leave it.
Thanks