Posts: 12
Threads: 4
Joined: Sep 2015
2015-09-19, 06:54:00
(This post was last modified: 2015-09-19, 07:11:16 by AndersonMM.)
I'm trying to put 3 different random images on the same page. In my template, I just put:
PHP Code:
<?php random_content('Square-Images'); ?>
<?php random_content('Square-Images'); ?>
<?php random_content('Square-Images'); ?>
But this causes occasional duplicate images. Is there a way to achieve this so there are 3 unique random images on the page every time?
Thank you.
Posts: 6,267
Threads: 182
Joined: Sep 2011
use an array and randomize the array
Posts: 3,491
Threads: 106
Joined: Mar 2010
I suppose AndersonMM is using the
Random Content plugin.
If so, function
random_content displays the output but doesn't return it, therefore it should be patched, or create a new modified one.
Posts: 12
Threads: 4
Joined: Sep 2015
(2015-09-19, 20:41:45)Carlos Wrote: I suppose AndersonMM is using the Random Content plugin.
If so, function random_content displays the output but doesn't return it, therefore it should be patched, or create a new modified one.
In this case, a randomized array using
random_content would not help me?
Posts: 6,267
Threads: 182
Joined: Sep 2011
You could use object buffering into an array and remove duplicates then randomize output.
Of course like I said
Getfiles() and array random is better
Posts: 12
Threads: 4
Joined: Sep 2015
shawn_a would you possibly be able to provide me a bit more of a snippet/example to get me going with that? Thank you for the Saturday support
Posts: 1,247
Threads: 82
Joined: Feb 2011
This topic might have some useful info: http://get-simple.info/forums/showthread.php?tid=6973