Show first image, then thumbs, skipping the first image

5 posts by 2 authors in: Forums > CMS Builder
Last Post: December 9, 2015   (RSS)

By crazyfish - December 8, 2015

Greetings,

I'm close on this one...   the counter only works on the first record ( hide first image thumb), then on all following records the first image shows up in the thumbs section.  I fell like I'm missing an easy logic issue here.

<?php foreach ($antique_stovesRecords as $record): ?>
    <div class="row dots">
    <div class="col-md-4 col-sm-6">        
    <?php foreach ($record['images'] as  $upload): ?>
      
<a href="<?php echo htmlencode($upload['urlPath']) ?>"rel="prettyPhoto[antique_stoves]"><img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" class="img-responsive center-block text-center" alt="<?php echo htmlencode($record['title']) ?>" /></a>
<?php break ?>
        <?php endforeach ?>
        
        
</div>
    <div class="col-md-8 col-sm-6 center-block ">
   <h3><?php echo htmlencode($record['title']) ?></h3>
      $<?php echo htmlencode($record['price']) ?><br/>
       <?php echo $record['content']; ?><br/>
      <strong>Dimensions:</strong> <?php echo htmlencode($record['size']) ?><br/>
      
      <?php foreach ($record['images'] as  $upload): ?>
<?php if (@++$count == 1) { continue; } ?>
<div class="col-md-3 col-sm-3 col-xs-3" style="padding-top:20px"><a href="<?php echo htmlencode($upload['urlPath']) ?>"rel="prettyPhoto[antique_stoves]"><img src="<?php echo htmlencode($upload['thumbUrlPath2']) ?>" class="img-responsive center-block text-center" alt="<?php echo htmlencode($record['title']) ?>" /></a></div>
<?php endforeach ?>
</div>
 </div>
 <?php endforeach ?>

This can be seen here   http://barnstablestove.com/new/html/parlor.php

Thanks as always

By Damon - December 8, 2015

It looks like you are just missing the code that assigns the $count a number to begin with. See the code added in bold

<?php foreach ($antique_stovesRecords as $record): ?>
    <div class="row dots">
    <div class="col-md-4 col-sm-6">        
    <?php foreach ($record['images'] as  $upload): ?>
      
<a href="<?php echo htmlencode($upload['urlPath']) ?>"rel="prettyPhoto[antique_stoves]"><img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" class="img-responsive center-block text-center" alt="<?php echo htmlencode($record['title']) ?>" /></a>
<?php break ?>
        <?php endforeach ?>
        
        
</div>
    <div class="col-md-8 col-sm-6 center-block "> 
   <h3><?php echo htmlencode($record['title']) ?></h3>
      $<?php echo htmlencode($record['price']) ?><br/>
       <?php echo $record['content']; ?><br/>
      <strong>Dimensions:</strong> <?php echo htmlencode($record['size']) ?><br/>
       <?php $count = 1; ?>
      <?php foreach ($record['images'] as  $upload): ?>
<?php if (@++$count == 1) { continue; } ?>
<div class="col-md-3 col-sm-3 col-xs-3" style="padding-top:20px"><a href="<?php echo htmlencode($upload['urlPath']) ?>"rel="prettyPhoto[antique_stoves]"><img src="<?php echo htmlencode($upload['thumbUrlPath2']) ?>" class="img-responsive center-block text-center" alt="<?php echo htmlencode($record['title']) ?>" /></a></div>
<?php endforeach ?>
</div>
 </div>
 <?php endforeach ?>

See if that gets the results you are after.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By crazyfish - December 9, 2015

I was hoping!  No dice...

By Damon - December 9, 2015

Hi,

Change this code:

<?php $count = 1; ?>

to this:

<?php $count = 0; ?>

That should do it as you are incrementing the counter before comparing so the previous set 1 was becoming 2. Setting the counter to 0 will then be increment to 1 and match the condition.

Let me know if this works for you.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/