Add Class after every 2nd record

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

By gkornbluth - April 9, 2015

Hi Craig,

Can’t get to testing this right now, but the approach I’d use is to add and increment a counter in your foreach record loop.

Then use an if statement around your <div> tag that looks for a counter value of 2, and if that condition is met, display the special code and reset the counter to a value of 0.

Something like this:

<?php $count = '0' ?>
<?php foreach ($testimonials_listPages as $record): ?>
<?php $count++ ?>
 <?php if($count == 2 ):?>
<?php $count = '0' ?>
<div class="one_half  animate" data-anim-type="fadeInLeft" data-anim-delay="100"> <?php else : ?> <div class="your_other_class”><?php endif ?>
... the rest of your code...


Hope that helps,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By KCMedia - April 9, 2015

thanks Jerry

that worked great cheers.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz