How to randomize a upload display

5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 5, 2010   (RSS)

By drewh01 - January 4, 2010

I have a site that will utilize website banner ads and they want 1 to appear randomly each time the page is reloaded.

How can this be done?

http://vps.fp2marketing.com/~chamberm

Here is my current code loading the uploads:

<?php foreach ($home_pageRecord['ad_space_1'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php endif ?>
<?php endforeach ?>

Re: [chris] How to randomize a upload display

By drewh01 - January 5, 2010

you are my hero!

Re: [drewh01] How to randomize a upload display

By Codee - January 5, 2010

Chris's method would be very stable, simple and fast (less server delay).

If you wanted the banners to rotate but on a timed increment instead of page refresh you could also incorporate some of the free code from dynamicdrive.com . I've done this for several clients to show thumbnails of product listings rotating every 2 seconds across the top of the page. I've also set up an "ad center" section inside CMSB for a client that allows them to change banner ads or banner code on the fly and appear automatically in certain pages and positions. CMSB makes this fairly easy and simple to do.

Re: [equinox69] How to randomize a upload display

By drewh01 - January 5, 2010

good to know, I appreciate it. May come in handy .