Showing selective images

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

By JeffC - November 4, 2014

Please can someone advise me how to show selected images

So instead of the code below which shows all uploads I would like to skip uploads 1 and 2 and begin with upload 3:

<?php if ($page['photos']): ?>

<?php foreach ($page['photos'] as $upload): ?>

<div class="thumbnail">
<img src="<?php echo $upload['thumbUrlPath2'] ?>" width="100%" title="<?php echo htmlspecialchars($upload['info1']) ?>" alt="<?php echo htmlspecialchars($upload['info3']) ?>" /><?php if ($upload['info1']): ?>

<div class="caption"><?php echo htmlspecialchars($upload['info2']) ?></div>
<?php endif ?>

thanks

Jeff

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