Setting a slide's status to active/not active

5 posts by 3 authors in: Forums > CMS Builder
Last Post: June 30, 2021   (RSS)

By Dave - May 25, 2021

Hi CommonSenseDesign, 

Try this: 

<?php $counter = 0; ?>
<?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?>
<?php
  $counter = $counter + 1;
  if ($counter = 1) { $class = "item active"; }
  else              { $class = "item"; }
?>
<div class="<?php echo $class; ?>">
  <div class="fill" style="background-image:url('<?php echo htmlencode($upload['urlPath']) ?>');">
    <div class="banner-content">
      <div class="container">
        <div class="row">
          <div class="banner-text al-left pos-left dark">
            <div class="animated fadeInUp">&nbsp;</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<?php endforeach ?>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

Hi, Dave.

Thanks for your advice. Sorry for taking so long to respond.

I tried your code, but unfortunately, it doesn't seem to have made any difference to the displaying of multiple images in the slideshow. It still only shows the top image in the list if the ones that have been loaded into CMSB.

https://www.castlerockcontracting.ca/home.php

Attachments:

home.php 8K

By Djulia - June 30, 2021 - edited: June 30, 2021

Hi CommonSenseDesign,

Change

<?php
  $counter = $counter + 1;
  if ($counter = 1) { $class = "item active"; }
  else              { $class = "item"; }
?>

with

<?php
  $counter = $counter + 1;
  if ($counter == 1) { $class = "item active"; }
  else               { $class = "item"; }
?>

Djulia