Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Random picture display

 

 


chassa2556
User

Jun 20, 2008, 2:44 PM

Post #1 of 2 (186 views)
Shortcut
Random picture display Can't Post

Hi

I would like to randomly display pictures on this index page.

http://www.straloch.com/

I have an index page section with a gallery loaded. Is there a way that each time the page refreshes it calls in a new image?

Many thanks in advance


Dave
Staff / Moderator


Jun 21, 2008, 12:45 PM

Post #2 of 2 (168 views)
Shortcut
Re: [chassa2556] Random picture display [In reply to] Can't Post

Hi Charles.

Did you figure this out already? When I reload the main page it seems like the image changes already?

If not, you can display just one image by adding a <?php break; ?> tag at the end of the image foreach loop like this. (Note my variable is called $newsRecord, yours might be named something else).


Code
<?php foreach ($newsRecord['uploads'] as $upload): ?> 
... display image here ...
<?php break; ?>
<?php endforeach ?>


Break means "break out of the loop" and only show one.

Next, you can shuffle the order of the uploads so the first one displayed will always be random. Just add this tag _before_ the foreach tag:


Code
<?php shuffle($newsRecord['uploads']); ?> 
<?php foreach ($newsRecord['uploads'] as $upload): ?>
...


Hope that helps! Let me know if you have any more questions about that.

Dave Edis - Senior Developer
interactivetools.com

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4