Showing selective images

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 25, 2014   (RSS)

By rconring - November 4, 2014

Try this:

<?php if ($page['photos']): ?>
    <?php $imageCount = 0 // Initialize counter ?>
    <?php foreach ($page['photos'] as $upload): ?>
      <?php $imageCount ++ // Increment the counter ?>
      <?php if($imageCount < 3):continue // slip first 2 array elements ?>
        <div class="thumbnail">      
          <!-- Image display code -->
        </div>      
    <?php endforeach ?>
<?php endif ?>

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By JeffC - November 25, 2014

Hi Ron

Thank you for your idea. It didn't quite work out for me but it got me on the right track. For anyone else that may be looking for a solution here's what i did:

<?php if ($page['photos']): ?>
<?php $uploadCount = 0; ?>
<?php foreach ($page['photos'] as $upload): ?>
<?php if (++$uploadCount < 3) { continue; } ?>
        
<div class="thumbnail">
<!-- Image display code -->
</div>
                
<?php endforeach ?>
<?php endif ?>

Jeff