Show first 3 images only in upload field

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 13, 2009   (RSS)

By benedict - October 5, 2009

Hi guys,

I am using an upload field and I only want to show the first three images in it on a page sidebar (the rest of them appear in a slideshow gallery).

I've seen use of <?PHP BREAK>, but that only shows the first image. Any tips?

Cheers!

Re: [benedict] Show first 3 images only in upload field

By Chris - October 6, 2009

Hi benedict,

Something like this should do the trick:

<?php $count = 0; ?>
<?php foreach ($record['uploads'] as $upload): ?>
<?php if (++$count > 3) { break; } ?>
display record...
<?php endforeach ?>


Hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Show first 3 images only in upload field

Hi Chris,

That works well - one other thing:

To make the images appear in random order, where do I put the "orderby" bit?

Cheers,

Benedict