Blank slide in Bootstrap 3 between every image slide - php

I've used Bootstrap carousel in my webpage but there is a problem in the slides. The first image slides with content, second is blank, then third image slides, then third image there is blank page slide.
My code:
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" ></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2" class="active"></li>
</ol>
<div class="carousel-inner">
<div class="item">
<img src="/site/img/daa.jpg" >
</div>
<div class="item">
<img src="/site/img/2.jpg" >
</div>
<div class="item active">
<img src="/site/img/grad.jpg" >
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
No margins, no padding, no .left or .right , and finally no spaces in the code..
What could the problem be?

Your code has some issues im edited your code Look at new updated and now you can understand Bootstrap Carousel Plugin
The Carousel plugin is a component for cycling through elements, like a carousel (slideshow).
Learn more about it W3SCHOOL
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="http://s32.postimg.org/osirordf9/2_black_wallpaper_pattern_preview.jpg" alt="First slide">
<div class="container">
</div>
</div>
<div class="item">
<img class="second-slide" src="http://s32.postimg.org/osirordf9/2_black_wallpaper_pattern_preview.jpg" alt="Second slide">
<div class="container">
</div>
</div>
<div class="item">
<img class="third-slide" src="http://s32.postimg.org/osirordf9/2_black_wallpaper_pattern_preview.jpg" alt="Third slide">
<div class="container">
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class

Thanks for your interest. I've used fiddle and tested my carousel, it worked fine there,
so after more effort, I detected the problem. It was because I have css file with
.next,.prev{
display: none !important;
}
but I don't understand deeply why it causes blank slide, not only white sides in my slides!
thanks again

Related

Bootstrap carousel image isn't loading when i attach it to my home page using php

So I've just been doing some homework and I've come across an issue and I can't seem to be able to fix it, I'm not sure if I'm missing something obvious or something but it's just not working.
First time using phpstorm btw
I'm using PHP files for a uni course I'm doing and I use the include function to attach this to the front page
I've gone through all these forums on bootstrap carousel errors and I tried even using a URL to see if that would work but it's not working still.
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../c-images/picture1.jpeg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../c-images/picture2.jpeg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../c-images/picture3.jpeg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
this is the HTML code in a file named carousel.php
and then in the front page named index.php, I have an include that includes this carousel.php
include'Includes/carousel.php';
the includes are all in a separate folder named Includes
Images are in another separate folder but when I refer to them I do use the ../ to go back one and then use the correct names to get to the image and use it.
So I'm a bit confused what's wrong if there's any common errors or something I can do to fix this?
As Far as I can understand your code. you need to take care of few things. the carousel.php you are working as only contains HTML code. So keep it simple. Don't use
any php syntax in it and place the Code like this as shown Below :
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active">
</li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../c-images/picture1.jpeg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../c-images/picture2.jpeg" alt="Second
slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../c-images/picture3.jpeg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button"
data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button"
data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
As I Have Removed quotes from around the Div.
and simply call the page using PHP as you are doing from index.php page. include'Includes/carousel.php';
But Remove Double quotes from there also and type it in under php Syntaxt as shown Below :
<?php include'Includes/carousel.php'; ?>
Ok i couldn't get it working.
But i figured if i added the html into the index.php instead of using include to include it into the page it might work, the images worked.
No to sure why by itself in an include file it didnt work but i will in the future look more into it.
Atleast i got the images working.

PHP only show photo in slider if value is not empty

I'm trying to make a slider and it works perfectly when 3 images are uploaded in the backend. It doesn't work when there are fewer.
The slider is a standard Bootstrap slider as seen here
The "the_field('afbeelding')" is from Advanced custom fields WP plugin as seen here
In the WP backend a user can upload an image, the_field('afbeelding') will print the url to the image.
For example, if there are only 2 images then it should only show 2 slides.
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" >
<div class="item active">
<img src="<?php the_field('afbeelding')?>" alt="<?php the_title() ?>">
</div>
<div class="item">
<img src="<?php the_field('afbeelding_2');?>" alt="">
</div>
<div class="item">
<img src="<?php the_field('afbeelding_3');?>" alt="">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
I tried to fix it by changing each item to this:
<?php if(isset(the_field('afbeelding_2'))){?>
<div class="item">
<img src="<?php the_field('afbeelding_2');?>" alt="">
</div>
<?php } ?>
But it didn't work...
Help would be very much appreciated!
you was almost there if you check the reference code for the advanced custom fields which you are using you will find out that if you want to check if the value exists for that field you need to use get_field() functions.
I didn't work before with this plugin but i believe the_field() is always returning true that's why you need to get_field() which return either true if the value exists or false if not and in this case your condition will work as expected .
<?php
if (get_field('afbeelding_2')) { ?>
<div class="item">
<img src="<?php the_field('afbeelding_2');?>" alt="">
</div>
<?php }?>
Reference

PHP, CodeIgniter

How to loop the data? All image are displaying at one slide other slides are empty.
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php foreach($banner as $data) { ?>
<div class="item active">
<img src="<?php echo base_url()?>uploads/banner/<?php echo $data['image']?>" alt="Chania" width="460" height="345">
</div>
<?php }?>
<div class="item">
<img src="<?php echo base_url()?>assets/image/c.jpg" alt="Chania" width="460" height="345">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
How to loop the data? All image are displaying at one slide other slides are empty.
Use the below code.
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$i = 0;
foreach($banner as $data) { ?>
<div class="item <?php echo $i==0 ? 'active' : ''; $i++; ?>">
<img src="<?php echo base_url()?>uploads/banner/<?php echo $data['image']?>" alt="Chania" width="460" height="345">
</div>
<?php }?>
</div>

Bootstrap carousel does not work with Laravel

I want to show on a carousel/slider the photos related to the last 3 posts that have been made on my page.
The $last3 variable gets the last three posts:
<div class="row carousel-holder">
<div class="col-md-12">
<div id="carousel-example-generic" class="product carousel slide" data-ride="carousel">
<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>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
#foreach($last3 as $post)
<div class="item active">
<div class="fill" style="background-image:url('../../images/Blog/{{$post->photo}}');"></div>
<h2>{{$post->title}}</h2>
</div>
#endforeach
</div>
<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>
</div>
</div>

Can not see carousel images

I want to create a carousel. This is my code:
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="/images/m1.jpg" alt="Poza 1" width="460" height="345">
</div>
<div class="item">
<img src="/images/m2.jpg" alt="Poza 2" width="460" height="345">
</div>
<div class="item">
<img src="/images/m3.jpg" alt="Poza 3" width="460" height="345">
</div>
<div class="item">
<img src="/images/m3.jpg" alt="Poza 3" width="460" height="345">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
I have all the pictures in the folder images...but they don't appear. So when I go in the images folder and I want to see the pictures, appear this:
Warning:
require_once(/home/files/public_html/6/skins/shinra/google_view.template.php) [function.require-once]: failed to open stream: No such file or
directory in /home/files/public_html/6/skins/shinra/view1.template.php
on line 19
Does anyone have an idea on whats going on and how I can fix it?

Categories