GetSimple Support Forum
[Solved] Need some help with displaying a random thumbnail from 2+ galleries - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: [Solved] Need some help with displaying a random thumbnail from 2+ galleries (/showthread.php?tid=4450)



[Solved] Need some help with displaying a random thumbnail from 2+ galleries - Alb - 2013-03-13

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


RE: Need some help with displaying a random thumbnail from 2+ galleries - mvlcek - 2013-03-13

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


RE: Need some help with displaying a random thumbnail from 2+ galleries - shawn_a - 2013-03-13

You could pick the gallery at random also.

PHP Code:
$gallery 'gallery'.rand(1,3);
get_i18n_gallery($gallery,array('url'=>$gallery'thumb'=>'random')); 



RE: Need some help with displaying a random thumbnail from 2+ galleries - Alb - 2013-03-17

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


RE: Need some help with displaying a random thumbnail from 2+ galleries - shawn_a - 2013-03-18

Then you just stick the names in an array and use the rand as the index when fetching it.


RE: Need some help with displaying a random thumbnail from 2+ galleries - shawn_a - 2013-03-18

Ill post code later if you can't figure it out


RE: Need some help with displaying a random thumbnail from 2+ galleries - Alb - 2013-04-02

(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