Php syntax for Bootstrap cart slider - php

I am trying to do the Cart slider which can be seen at http://bootsnipp.com/snippets/Pbnxx
I am struggling with proper PHP syntax. Can anyone help me out?
The way I see it that I need to prepend .item and .row for every 4 columns, but something is glitching and doesn't work as expected
<div class="container">
<div class="row">
<div class="col-md-9">
<h3>TITLE </h3>
</div>
<div class="col-md-3">
<!-- Controls -->
<div class="controls pull-right hidden-xs">
<a class="left fa fa-chevron-left btn btn-success" href="#carousel-example"
data-slide="prev"></a>
<a class="right fa fa-chevron-right btn btn-success" href="#carousel-example"
data-slide="next"></a>
</div>
</div>
</div>
<div id="carousel-example" class="carousel slide hidden-xs" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php
while ( $query->have_posts() ) :
$query->the_post();
// make new slide every 4 columns
if($i % 4 == 0) : ?>
<div class="item <?php if($a++ == 0) echo 'active'; ?>">
<div class="row">
<?php endif; ?>
<div class="col-sm-3">
<div class="col-item">
<?php echo $i; ?>
</div>
</div>
<!-- end slide every 4 columns -->
<?php if($i++ % 4 == 0) : ?>
</div> <!-- row -->
</div> <!-- slide -->
<?php endif; ?>
<?php endwhile; ?>
</div> <!-- end carousel -->
</div> <!-- carousel-example -->
</div> <!-- container -->

I think your .row should be also .item because you want to slide 4 items at time.

Here you have my code using smarty. I used array_chunk($items, 4) and nested loops.
<div class="carousel-inner">
{foreach $recipebox.recipes as $key=>$recipeSet}
{if $key == 0}
<div class="row item active">
{else}
<div class="row item">
{/if}
{foreach $recipeSet as $recipe }
<div class="col-xs-3">
// box content
</div>
{/foreach}
</div>
{/foreach}
</div>

Related

The listed items doesn't align and skip 2 item space in a row

I have problem in listing the products 3 in a row the line get broken at the 4th
when it's at the 4th item it's listing them like
1. row 1 1 1
2. row 0 0 1
3. row 1 0 0
4. row 1 1 1
5. row 0 0 1
I can't find where is the problem.
I checked the bootstrap container structure. It's says the first col after the row is the left the second is the center and the third is the right.
I made 3 col in a row but that didn't work i can't use the left side it's like the container has only center and right side. So the size of the items not fitting the container thats why it's skipping as i find when i make the item size <div class="col-md-2"> the items get in the line correct but they become smaller. I need them <div class="col-md-3"> everything get broken when it's become 3 or 4
<?php
include "header.php";
$id=isset($_GET['kategori_id']) ? $_GET['kategori_id']:"";
$kitap_cek_miktar = 12;
$sql=$db->prepare("SELECT COUNT(*) AS kayit_sayisi FROM kitap_bilgi where kategori_id=$id ");
$sql->execute();
$kayit_say=$sql->fetch(PDO::FETCH_ASSOC);
$kayit_sayisi = $kayit_say['kayit_sayisi'];
$sayfa_sayisi=ceil($kayit_sayisi/$kitap_cek_miktar);
if (!isset($_GET['sayfa'])) {
$sayfa=1;
}else{
$sayfa=$_GET['sayfa'];
}
$ilk_kayit=($sayfa-1)*$kitap_cek_miktar;
$resim=$db->prepare("SELECT kitap_ad,kitap_resim, kitap_fiyat,kitap_id from kitap_bilgi where kategori_id=$id LIMIT ".$ilk_kayit.",".$kitap_cek_miktar);
$resim->execute();
$veri = $resim->fetchAll(PDO::FETCH_ASSOC); // tablo verilerini oku
?>
<div class="container">
<!--- this stucture is like a banner for an e-commerce website --->
<div class="row">
<div class="col-md-12">
<div class="page-title-wrap">
<div class="page-title-inner">
<div class="row">
<div class="col-md-4">
<div class="bread">Home › Category</div>
<div class="bigtitle">Category</div>
</div>
<div class="col-md-3 col-md-offset-5">
<button class="btn btn-default btn-red btn-lg">Purchase Theme</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--->
<div class="row">
<div class="col-md-9"><!--Main content-->
<div class="title-bg"> <!--- this stucture is to change the list way an e-commerce website --->
<div class="title">Category - All products</div>
<div class="title-nav">
<i class="fa fa-th-large"></i>grid
<i class="fa fa-bars"></i>List
</div>
</div> <!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--->
<div class="row prdct"><!--Products listing the products pic, price, name -->
<?php foreach($veri as $kayit): ?>
<div class="col-md-4"> <!-- items list size -->
<div class="productwrap">
<div class="pr-img">
<a href="urun_detay.php?kitap_id=<?= $kayit['kitap_id']?>">
<img src="images/<?= $kayit['kitap_resim']?>" alt="<?= $kayit['kitap_ad']?>" class="img-responsive">
</a>
<div class="pricetag">
<div class="inner"><?= $kayit['kitap_fiyat'].'₺'?></div>
</div>
</div>
<span class="smalltitle">
<?= $kayit['kitap_ad'].$kayit['kitap_id']?>
</span>
</div>
</div>
<?php endforeach; ?>
</div><!--Products ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--->
<ul class="pagination shop-pag"><!--pagination making the pages 1.2.3 next -->
<?php for ($sayfa=1;$sayfa<=$sayfa_sayisi;$sayfa++)
{
echo '<li>
' . $sayfa . '
</li> ';
} ?>
</ul><!--pagination--><!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--->
</div><!--Main content-->
<div class="col-md-3"><!--sidebar listing the categories -->
<div class="title-bg">
<div class="title">Categories</div>
</div>
<div class="categorybox">
<?php categories();?>
</div>
</div><!--sidebar-->
</div>
</div>
<?php
include('footer.php');
?>

Dynamic div close in php while loop

code i have written below is working fine but at the end of the looping the div is not closed its still opening a loop
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$recent_projects_sql="SELECT * from recent_projects where service_type='upholstery'";
$recent_projects_conn=mysql_query($recent_projects_sql) or die(mysql_error());
$i=0; $split=0;
while($projects=mysql_fetch_array($recent_projects_conn)) {
$i++;
?>
<div class="col-sm-3">
<div class="col-item" style="">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/<?php echo $projects['attachment1']; ?>" alt="User one">
</div>
<div class="info">
<div class="name">
<?php echo $projects['service_name']; ?>
</div>
<div class="degination">
<?php echo $projects['sub_title']; ?>
</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php
$split++;
if ($split % 4 == 0){
echo '</div></div><div class="item"><div class="row">';
}
}
?>
</div>
</div>
The Div has splited very well but in end of the loop div has not been closed. Thats only the problem please provide me the help to sort out the problem
When I inspect the element the last loop will show at the given result as follows:
<div class="col-sm-3">
<div class="col-item">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/1557301934.jpg" alt="User one">
</div>
<div class="info">
<div class="name">UPHOLSTERY</div>
<div class="degination">UPHOLSTERY</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div></div><div class="item"><div class="row">
I want to remove the two opening div's as dynamically. How can i set this to remove opened div's at then end of the looping
I just took a quick look and it looks like you are not closing the "carousel-inner" div
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$recent_projects_sql = "SELECT * from recent_projects where service_type='upholstery'";
$recent_projects_conn = mysql_query( $recent_projects_sql ) or die( mysql_error() );
$i = 0;
$split = 0;
while ( $projects = mysql_fetch_array( $recent_projects_conn ) ) {
$i ++;
?>
<div class="col-sm-3">
<div class="col-item" style="">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/<?php echo $projects['attachment1']; ?>"
alt="User one">
</div>
<div class="info">
<div class="name">
<?php echo $projects['service_name']; ?>
</div>
<div class="degination">
<?php echo $projects['sub_title']; ?>
</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php $split ++;
if ( $split % 4 == 0 ) {
echo '</div></div><div class="item"><div class="row">';
}
}
?>
</div>
</div>
Add a Boolean check for the execution of loop, such as $check = true;, add this within the loop.
after the loop add this
if($check){
echo " </div></div>";
}
That's because at the end of iteration (in case of mod 4 and even without it), you keep 2 divs opened
echo '</div></div><div class="item"><div class="row">';

Why some custom fields in a section of my WordPress website aren't working?

I'm building a WordPress website. Everything went fine before using custom post types. When I use CPT and write PHP code then a section can't print the custom fields. This affects only one section. Other sections and custom fields works fine.
Before adding this code the custom field worked fine:
<?php
$args = array("post_type" => "project_feature");
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="col-sm-4">
<?php
if(has_post_thumbnail())
{
the_post_thumbnail();
}
?>
<h3><?php the_title(); ?></h3>
<div class="black_text"><?php the_content(); ?></div>
</div> <!-- col -->
<?php endwhile; wp_reset_query(); ?>
But now if I delete this code my custom feature still doesn't work. I don't understand what I am doing wrong. I still don't know if it's my code or something else in WordPress.
This custom fields within the instructor section aren't working:
<?php
// instructor custom fields
$instructor_name = get_field('instructor_name');
$instructor_description = get_field('instructor_description');
$students = get_field('students');
$views = get_field('views');
$courses = get_field('courses');
?>
<!-- INSTRUCTOR
=========================================
-->
<section id="instructor">
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-sm-8">
<h3>Your Instructor <small><?php echo $instructor_name; ?></small></h3>
</div> <!-- col -->
<div class="col-sm-4">
<ul>
<li>
<i class="fa fa-facebook social" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-google-plus social" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-linkedin social" aria-hidden="true"></i>
</li>
</ul>
</div> <!-- col -->
</div> <!-- row -->
<div class="row">
<div class="col-sm-12">
<p class="black_text"><?php echo $instructor_description; ?></p>
<hr>
</div> <!-- col -->
</div> <!-- row -->
<div class="row">
<div class="col-sm-12">
<h3>The numbers <small>They don't lie...</small></h3>
</div> <!-- col -->
<div class="col-sm-4 round_display">
<p class="black_text"><?php echo $students; ?> students</p>
</div> <!-- col -->
<div class="col-sm-4 round_display">
<p class="black_text"><?php echo $views; ?> views</p>
</div> <!-- col -->
<div class="col-sm-4 round_display">
<p class="black_text"><?php echo $courses; ?> courses</p>
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- col -->
<div class="col-sm-6">
<img src="<?php bloginfo('stylesheet_directory'); ?>/image/brad.png" alt="man" class="img-responsive center-block income_image"/>
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
</section> <!-- INSTRUCTOR -->

iframe play button is working as carousel left indicator

I am trying to display videos as a slideshow inside bootstrap modal dynamically. But when videos are loaded, the corresponding play button functions as carousel left indicator. And also the video is auto-playing. I also tried using tag, which stops the auto-play, but still the play button functioning as carousel left indicator. Thanks in advance.
Below is my code.
<div class="modal fade and carousel slide" id="video">
<div class="modal-dialog" style="margin-top:250px;" >
<div class="modal-content">
<div class="modal-body">
<div class="carousel-inner">
<?php
$id=$_GET['id'];
//$i=0;
$qryr="select * from released_movies where rel_id='$id' ";
$qryrr=$con->query($qryr);
while($rrr=$qryrr->fetch_assoc()){
$film=$rrr['rel_movies'];
$qq="select * from events where film='$film'";
$qrr=$con->query($qq);
while($roo=$qrr->fetch_assoc()){
$rowss[] = $roo;
}
?>
<ol class="carousel-indicators">
<?php
$i = 1; //Counter
foreach ($rowss as $roo): //Foreach
$ol_class = ($i == 1) ? 'active' : ''; //Set class active for only indicator which belongs to respective Image
?>
<!--Here I add the counter to data-slide attribute and add class to indicator-->
<li data-target="#video" data-slide-to="<?php echo $i;?>" class="<?php echo $ol_class; ?>"></li>
<?php $i++; ?>
<?php endforeach; ?> <!--Close Foreach-->
</ol>
<?php
$i = 1; //Counter
foreach ($rowss as $roo): //Foreach
$item_class = ($i == 1) ? 'item active' : 'item'; //Set class active for image which is showing
?>
<div class="<?php echo $item_class; ?>"> <!-- Define Active Class Here-->
<iframe width="100%" height="500px" src="../AbaamAdmin/Events_Videos/<?php echo $roo['event_videos'];?>" frameborder="0" allowfullscreen></iframe>
</div>
<?php $i++; ?>
<?php endforeach; ?> <!-- Close Foreach-->
</div> <!-- /.item active-->
<a class="left carousel-control" href="#video" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<!-- <span class="glyphicons glyphicons-left-arrow"></span>-->
</a>
<a class="right carousel-control" href="#video" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<!--<span class="glyphicons glyphicons-right-arrow"></span>-->
</a>
<?php } ?>
</div> <!-- /.carousel-inner -->
</div><!-- /.modal-body -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
In your approach, some div elements, selectors are misplaced and one key div is missing, need some CSS changes required.
"carousel slide" in Modal HTML (Remove it)
<div class="carousel-inner"> is misplaced, it should come after <ol class="carousel-indicators"></ol>
Missing key carousel Element <div id="selector" class="carousel slide" data-ride="carousel"> Add it after modal-body
In Prev and Next button you are targeting href="#video" which is the id of Modal
In carousel indicators you are targeting data-target="#video" which is the id of Modal
CSS Changes required to fix the issue when clicking on Play / Stop button causing the video slide to next, Reason the Next / Previous button is overlapping the video control, following changes in CSS will fix the issue
.carousel-control {
bottom: 55px !important;
}
To stop the auto play, add autoplay=false in video iframe.
Final HTML will be
Note: I named the carousel selector id videobox
<div class="modal fade and" id="video">
<div class="modal-dialog" style="margin-top:250px;" >
<div class="modal-content">
<div class="modal-body">
<div id="videobox" class="carousel slide" data-ride="carousel">
<?php
$id=$_GET['id'];
//$i=0;
$qryr="select * from released_movies where rel_id='$id' ";
$qryrr=$con->query($qryr);
while($rrr=$qryrr->fetch_assoc()){
$film=$rrr['rel_movies'];
$qq="select * from events where film='$film'";
$qrr=$con->query($qq);
while($roo=$qrr->fetch_assoc()){
$rowss[] = $roo;
}
}
?>
<ol class="carousel-indicators">
<?php
$i = 1; //Counter
foreach ($rowss as $roo):
$ol_class = ($i == 1) ? 'active' : '';
?>
<li data-target="#videobox" data-slide-to="<?php echo $i;?>" class="<?php echo $ol_class; ?>"></li>
<?php $i++; ?>
<?php endforeach; ?>
</ol>
<div class="carousel-inner">
<?php
$i = 1; //Counter
foreach ($rowss as $roo):
$item_class = ($i == 1) ? 'item active' : 'item';
?>
<div class="<?php echo $item_class; ?>">
<iframe width="100%" height="500px" src="../AbaamAdmin/Events_Videos/<?php echo $roo['event_videos'];?>" frameborder="0" allowfullscreen autoplay="false"></iframe>
</div>
<?php $i++; ?>
<?php endforeach; ?>
</div> <!-- /.item active-->
<a class="left carousel-control" href="#videobox" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<!-- <span class="glyphicons glyphicons-left-arrow"></span>-->
</a>
<a class="right carousel-control" href="#videobox" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<!--<span class="glyphicons glyphicons-right-arrow"></span>-->
</a>
</div> <!-- /.carousel-inner -->
</div><!-- /.modal-body -->
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Fiddle

Single page WordPress theme

I made a single page HTML to WordPress website. There are 4 sections and 4 menu items. The section id and menu id are the same (ordering by page order).
Basically in the HTML format when you click on the menu, the scroll bar automatically goes to the related section. When I turn it into WordPress everything is working but when I click over the menu it doesn't.
<!-- Menu section -->
<div class="col-md-8 col-sm-10 col-xs-4 main-menu text-right">
<ul class="menu-first hidden-sm hidden-xs">
<?php
global $post;
$args = array('post_type'=>'page','orderby'=>'menu_order','order'=>'ASC');
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post);?>
<li><?php the_title(); ?></li>
<?php endforeach; ?>
</ul>
<i class="fa fa-bars"></i>
</div> <!-- /.main-menu -->
<!-- Service -->
<div class="content-section" id="<?php echo $post->post_name; ?>">
<div class="container">
<div class="row">
<div class="heading-section col-md-12 text-center">
<h2>Services</h2>
</div> <!-- /.heading-section -->
</div> <!-- /.row -->
<div class="row">
<?php
global $post;
$args = array('post_type'=>'service','orderby'=>'menu_order','order'=>'ASC');
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
<div class="col-md-3 col-sm-6">
<div class="service-item" id="service-1">
<div class="service-icon">
<i class="fa fa-<?php echo $service_icon; ?>"></i>
</div> <!-- /.service-icon -->
<div class="service-content">
<div class="inner-service">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div> <!-- /.service-content -->
</div> <!-- /#service-1 -->
</div> <!-- /.col-md-3 -->
<?php endforeach; ?>
</div> <!-- /.row -->
</div> <!-- /.container -->
</div> <!-- /#services -->
Related code located also at paste bin.
I don't see any anchors with name attributes for your link to actually jump to. Try this:
<?php foreach($myposts as $post) : setup_postdata($post); ?>
<div class="col-md-3 col-sm-6">
<div class="service-item" id="service-1">
<!-- Rest of markup removed for clarity -->
<h3>
<a name="<?php echo $post->post_name; ?>"><?php the_title(); ?></a>
</h3>
</div>
</div>
<?php endforeach; ?>

Categories