Slideshow problem

11 posts by 3 authors in: Forums > CMS Builder
Last Post: December 1, 2014   (RSS)

By CommonSenseDesign - November 21, 2014

I have a slideshow that uses the following code:

<div id="carousel-example-generic" class="carousel  slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner">

<div class="item active">
<img src="img/image-01.jpg" alt="">
<div class="carousel-caption">
<div class="jumbotron__container">Caption 1</div>
</div>
</div>


<div class="item">
<img src="img/image-02.jpg" alt="">
<div class="carousel-caption">
<div class="jumbotron__container">Caption 2</div>
</div>
</div>

</div>

<!-- Controls -->
<a class="left  carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon  glyphicon-chevron-left"></span>
</a>
<a class="right  carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon  glyphicon-chevron-right"></span>
</a>
</div>

I'm trying to replicate this with CMSB, but the slideshow images don't show up:

<div id="carousel-example-generic" class="carousel  slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?>    
<div class="item">
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<div class="carousel-caption">
<div class="jumbotron__container">
<?php echo htmlencode($upload['info1']) ?>
</div>
</div>
</div>
<?php endforeach ?>


<!-- Controls -->
<a class="left  carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon  glyphicon-chevron-left"></span>
</a>
<a class="right  carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon  glyphicon-chevron-right"></span>
</a>
</div>

Any idea where I'm going wrong, please?

By Damon - November 24, 2014

Hi,

Here is the code that is missing:

<div class="item active">

Looks like this needs to appear for the first image and then the following ones use this code:

<div class="item">

To do this, you can start a counter, use a if statement to only display the first line of code if the counter is 1 or else display the 2nd line of code. 
Make sure you increment your counter inside the loop so it only matches one time :  $counter++

Let me know if this make sense and/or if you have any questions.

Cheers,
Damon Edis - interactivetools.com

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

By CommonSenseDesign - November 24, 2014

Thanks for the reply, Damon.

I noticed that difference between the static and CMSB code, but don't know how to get only the first slide to have the "active" setting. Can you point me in the right direction, please?

By Damon - November 24, 2014

Hi again,

Try this code:

<div id="carousel-example-generic" class="carousel  slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php $counter = 1; ?>
<?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?>  
<?php if($counter == 1) : ?>
<div class="item active">
<?php else : ?>
<div class="item">
<?php endif; ?>  
<div class="item">
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
<div class="carousel-caption">
<div class="jumbotron__container">
<?php echo htmlencode($upload['info1']) ?>
</div>
</div>
</div>
<?php $counter++; ?>
<?php endforeach ?>


<!-- Controls -->
<a class="left  carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon  glyphicon-chevron-left"></span>
</a>
<a class="right  carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon  glyphicon-chevron-right"></span>
</a>
</div>

And if this doesn't work, send me an email with your FTP details (don't post here) to support@inteactivetools.com so I can help.

Cheers,
Damon Edis - interactivetools.com

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

By Damon - November 26, 2014

Hi,

I use a program called WinMerge to compare the code for the working slideshow and the broken one.

Here is the code that is different:

<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>

For the working one, there is a list item for each image with an increment number for the data-slide-to. Also the first image list item has class="active".

Will write up some code for this, test and post soon.

Cheers,
Damon Edis - interactivetools.com

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

By claire - December 1, 2014

Hi there, can you try this code? I think there's a misaligned closing <div> tag that needs to be fixed.

<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?>  
<div class="item<?php echo $index == 0 ? ' active' : ''; ?>"> 
<img src="<?php echo $upload['urlPath'] ?>" />
<div class="carousel-caption">
<div class="jumbotron__container">
<?php echo htmlencode($upload['info1']) ?>
</div>
</div>
<?php endforeach ?>
</div>

--------------------

Claire Ryan
interactivetools.com

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

By claire - December 1, 2014

There is definitely a missing div tag here somewhere. Let's try again:

<div id="carousel-example-generic" class="carousel  slide" data-ride="carousel">
<!-- Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">

        <?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?> 
        <div class="item<?php echo $index == 0 ? ' active' : ''; ?>">
            <img src="<?php echo $upload['urlPath'] ?>" alt="">
            <div class="carousel-caption">
                <div class="jumbotron__container"><?php echo htmlencode($upload['info1']) ?></div>
            </div>
        </div>
        <?php endforeach; ?>

    </div>

    <!-- Controls -->
    <a class="left  carousel-control" href="#carousel-example-generic" data-slide="prev">
        <span class="glyphicon  glyphicon-chevron-left"></span>
    </a>
    <a class="right  carousel-control" href="#carousel-example-generic" data-slide="next">
        <span class="glyphicon  glyphicon-chevron-right"></span>
    </a>
</div>

This should replace all your code, it's basically the same as what you originally posted except with the proper PHP added.

--------------------

Claire Ryan
interactivetools.com

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

By CommonSenseDesign - December 1, 2014

Major success! http://www.mountainoakcheese.com/index1.php

The only minor thing is the circles that appear near the bottom of the slides. I can only see two, whereas there should be three to match the number of slides.

By claire - December 1, 2014

Ah, I see the indicators need to be changed as well. Try this:

<div id="carousel-example-generic" class="carousel  slide" data-ride="carousel">
<!-- Indicators -->
    <ol class="carousel-indicators">
        <?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?>
        <li data-target="#carousel-example-generic" data-slide-to="<?php echo $index; ?>"<?php echo $index == 0 ? ' class="active"' : ''; ?>></li>
        <?php endforeach; ?>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">

        <?php foreach ($homepageRecord['slideshow'] as $index => $upload): ?> 
        <div class="item<?php echo $index == 0 ? ' active' : ''; ?>">
            <img src="<?php echo $upload['urlPath'] ?>" alt="">
            <div class="carousel-caption">
                <div class="jumbotron__container"><?php echo htmlencode($upload['info1']) ?></div>
            </div>
        </div>
        <?php endforeach; ?>

    </div>

    <!-- Controls -->
    <a class="left  carousel-control" href="#carousel-example-generic" data-slide="prev">
        <span class="glyphicon  glyphicon-chevron-left"></span>
    </a>
    <a class="right  carousel-control" href="#carousel-example-generic" data-slide="next">
        <span class="glyphicon  glyphicon-chevron-right"></span>
    </a>
</div>

--------------------

Claire Ryan
interactivetools.com

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