Aternating row content

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 14, 2015   (RSS)

By Damon - October 14, 2015

Hi,

Here is some example code that you can use to get the different layouts for each row. Modify as needed:

<?php $counter = 1; ?>
<?php foreach ($newsRecords as $record): ?>
<?php if($counter % 2) : ?>   
 <!-- ROW 1 -->   
 <?php foreach ($record['image'] as $index => $upload): ?>   
 <img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" align="left" />   
 <?php break; // show only one image ?>   
 <?php endforeach; ?>   
 <?php echo htmlencode($record['title']) ?><br/>   
 <br clear="left" />
<?php else : ?>
 <!-- ROW 2 -->  
 <?php foreach ($record['image'] as $index => $upload): ?>   
 <img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" align="right" />   
 <?php break; // show only one image ?>   
 <?php endforeach; ?>   
 <?php echo htmlencode($record['title']) ?><br/>   
 <br clear="all" />
<?php endif; ?>       
 <?php $counter++; ?>
<?php endforeach ?>

Cheers,
Damon Edis - interactivetools.com

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

By terryally - October 14, 2015

Hi Damon,

Many thanks for your swift response and excellent code which worked perfectly without the htmlencode().

Thanks again

Terry