i want to add bootsnipp slider in codeigniter - codeigniter

Here is my main view page :
the first class: item active ,
and another is only class: item
but i want foreach only class="col-sm-6" with two class item active and item ...
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-sm-6">
<div class="col-item">
<div class="photo">
<img src="img/a.jpg" />
</div>
<div class="info">
<div class="row">
<div class="price col-md-6">
<h5>title</h5>
<h5 class="price-text-color">
Contact for price</h5>
</div>
<div class="rating hidden-sm col-md-6">
<i class="fa fa-bed"></i> <b>3</b>
<i class="fa fa-bath"></i> <b>2</b>
</div>
</div>
<div class="separator clear-left">
<p class="btn-details">
<i class="fa fa-list"></i>More details</p>
</div>
<div class="clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-sm-6">
<div class="col-item">
<div class="photo">
<img src="2.jpg" />
</div>
<div class="info">
<div class="row">
<div class="price col-md-6">
<h5>title</h5>
<h5 class="price-text-color">
Contact for price</h5>
</div>
<div class="rating hidden-sm col-md-6">
<i class="fa fa-bed"></i> <b>5</b>
<i class="fa fa-bath"></i> <b>3</b>
</div>
</div>
<div class="separator clear-left">
<p class="btn-details">
<i class="fa fa-list"></i>More details</p>
</div>
<div class="clearfix">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
but when i foreach the div one is active class but i want one div is active but another is not . actually i want to foreach col-sm-6 class.. how to do this. first

I assume that you want the following:
for there to be one active item
for each item to contain several col-sm-6 elements, created via a php foreach loop
create item via a php foreach loop
<!-- language: lang-php -->
<?php $active_item = "active" ?>
<?php foreach($itemlist as $item): ?>
<div class="item <?php echo $active_item ?>">
<?php $active_item = "" ?>
<div class="row">
<?php foreach($item as $column): ?>
<div class="col-sm-6">
<!-- insert your logic here for creating your columns in a carousel -->
</div>
<?php endforeach ?>
</div>
</div>
<?php endforeach ?>
$active will append the active class to only the first instance of your carousel items.
I avoided using foreach($array as $key=>$value) and checking the key for whether the item is to be active, as your array may not have numerical keys that begin with 0.

Related

wire:click only works for the first item in foreach in livewire

I want to open a model for edit item. I have added wire:click on a div but that only works for the first item of foreach.
Livewire Method
public function selectMealPlan($mealId)
{
$this->dispatchBrowserEvent('openEditMealModal');
}
View file
#foreach ($meal_plans as $meal)
<div class="meals-plan-item">
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
</div>
#endforeach
<script>
window.addEventListener('openEditMealModal', function() {
alert('hello');
})
</script>
The component should have only one root element, a div for example:
<div class="meals-plan-item">
#foreach ($meal_plans as $meal)
<div class="meals-plan-item-type">
<div class="meals-plan-item-label" wire:click="test">MEAL TYPE:</div>
<div class="meals-plan-item-value">{{ $meal->meal_type }}</div>
</div>
<div class="meals-plan-item-names">
<div class="meals-plan-item-label">MEAL NAMES:</div>
<div class="meals-plan-item-value">{{ $meal->getMealItems() }}</div>
</div>
<div class="meals-plan-item-actions">
<div class="action-button edit" wire:click="selectMealPlan({{ $meal->id }})">
<i class="fas fa-pencil"></i>
</div>
<div class="action-button delete" data-toggle="modal" data-target="#deletePlan{{ $meal->id }}">
<i class="fas fa-trash"></i>
</div>
</div>
#endforeach
</div>

Dynamic Carousel In Laravel not displaying proper data

<div class="container mt-4 mb-4">
<div class="row">
<div class="col-lg-12">
<div id="blogCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
#foreach($reviews as $items)
<div class="carousel-item #if($loop->first) active #endif">
<div class="row">
#foreach($reviews as $review)
<div class="col-lg-4 ">
<a>
<div class="home1-img mt-3">
<?php
for($i=1;$i<6;$i++){
$check = '';
if($review->number_of_stars >= $i){
$check = 'checked';
}
echo '<span class="fa fa-star '.$check.'"></span>';
}
?>
<div class="home1-text mt-1" style="margin-bottom:30px;">
<p>{!! Illuminate\Support\Str::limit($review->customer_review,100) !!}</p>
<h5 class="text-color font-weight-bold">{{ $review->customer_name }}</h5>
</div>
</div>
</a>
</div>
#endforeach
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
I am getting all the records in all sides but I want 3 records in 1st slide then 3 records in 2nd slide and so on. I have tried many times but I am not able to fix it.

Unable to show category wise data in sections of home page

I want to fetch category wise data in home page's sections but I am unable to do this. Only one category section is working[enter image description here][1]
I made Section model and under this model Category model My IndexController Code :
<?php
namespace App\Http\Controllers\Front;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Slider;
use App\Category;
use App\Section;
class IndexController extends Controller
{
public function index(){
$sliders = Slider::where('status',1)->get();
$categories = Category::with('sections')->where('status',1)->get();
//dd($categories);die;
return view('frontend.index')->with(compact('sliders','categories'));
}
}
and blade file code is :
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best tours</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Tours")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best stays</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Stays")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
<section class="latest_work">
<div class="container">
<div class="row sub_content">
<div class="col-md-12">
<div class="dividerHeading">
<h4><span>Find your best cars</span></h4>
</div>
<div id="recent-work-slider" class="owl-carousel">
#foreach($categories as $category)
#if($category['sections']['section_name'] == "Cars")
<div class="product">
<figure class="touching effect-bubba">
<div class="product-img">
<img class="img-responsive" src="{{ asset('images/categories/'.$category['category_banner']) }}">
<div class="option">
<a class="fa fa-shopping-cart" href="portfolio_single.html"></a>
<a class="fa fa-search mfp-image" href="{{ asset('images/categories/'.$category['category_banner']) }}"></a>
</div>
</div>
</figure>
<div class="product-info">
<div class="product-title">
<h3>
{{ $category['category_name'] }}
</h3>
</div><br>
</div>
</div>
#endif
#endforeach
</div>
</div>
</div>
</div>
</section>
only one tours section's categories is showing but not showing other categories
Yes Only one tour sections is showing because of this condition in your code
#if($category['sections']['section_name'] == "Tours")
........................
#endif

Deleting files that belong to a post?

I have two tables called 'posts' and 'photos'. The 'photos' table store the images for the 'post'. A post can have many photos so the relationship is one-to-many. I've managed to create the store method, I already create the view to show a post with its photos as well. Below is the function :
public function show($titleslug) {
$post = Post::where('titleslug', '=', $titleslug)->first();
$images = $post->photos;
return view('dashboard/posts/show', compact('post','images', $post, $images));
}
The show view :
<div class="contentpanel">
<div class="row blog-content">
<div class="col-sm-12">
<div class="panel panel-default panel-blog">
<div class="panel-body">
<div class="panel-body">
<h3 class="blogsingle-title">{{$post->title}}</h3>
<ul class="blog-meta">
<li><i class="fa fa-clock-o"></i> Jan 02, 2014</li>
</ul>
<div class="mb20"></div>
{!! $post->content !!}
</div><!-- panel-body -->
<div class="mb20"></div>
</div><!-- panel-body -->
</div><!-- panel -->
</div><!-- col-sm-8 -->
</div><!-- row -->
<div class="row blog-content">
<div class="col-sm-12">
<div class="panel panel-default panel-blog">
<div class="panel-body">
<h3 class="blogsingle-title">This post featured images :</h3>
<div class="mb20"></div>
<?php foreach ($images as $i): ?>
<div class="col-xs-12 col-sm-4 col-md-3">
<div class="blog-item">
<img src="{{asset('image/'. $i->image)}}" class="img-responsive" alt="" style="height: 150px;"/>
<div class="blog-details">
<ul class="blog-meta">
<li><a class="btn btn-sm btn-warning" title="Edit" href="#"><i class="fa fa-edit"></i></a></li>
<form action="#" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<li>
<button type="submit" class="btn btn-sm btn-danger" title="Delete" onclick="return confirm('Are you sure deleting this photo ?');"><i class="fa fa-trash-o"></i></button>
</li>
</form>
</ul>
</div>
</div><!-- blog-item -->
</div><!-- col-xs-6 -->
<?php endforeach; ?>
</div>
<div class="panel-body">
<div class="alert alert-info fade in">
<p>
<button type="button" class="btn btn-info">Add New Images</button>
</p>
</div>
</div>
</div><!-- panel -->
</div>
</div>
</div><!-- contentpanel -->
I want to be able to delete the images from the show view, how to do that ? Do I need to create a function to it ? If so, then how will the function looks like ?
That's all and thanks, sorry for asking too much
First, edit your delete form in the view by adding :
...
<input type="hidden" name="image_id" value="{{ $images->id }}" /> // Assuming that photo id is in your $images object
...
Then, you could create a POST route image/delete associated to delete function from your controller to remove the expected image :
public function delete() {
$image_id = $request->only('image_id');
$image = Photo::where('id', '=', $image_id)->delete(); // Assuming that you have a Photo model
return view('dashboard/posts/show');
}

xpath specific selection with condition

this might be simple, but I would like to select everything within <div class="rc-box-citations-body"> under the condition that it must belong to <div class="definitionBox" id="meaning-1-1">, thereby uniquely identifying it. How can I do that with xpath? Thanks.
<div class="definitionIndent">
<div class="definitionNumber">1.a</div>
<div class="definitionIndent">
<div class="definitionBox" id="meaning-1-1">
<span class="textmedium">
<span class="stampNoBorder">text</span>
<span class="definition">text</span>
</span>
</div>
<div class="definitionBox">
<div class="rc-box-citations">
<div class="rc-box-citations-top">
<span class="rc-citations-north-west"> </span>
<span class="rc-citations-north-east"> </span>
</div>
<div class="rc-box-citations-body"><span class="citat">text</span> <a class="sourcepop" href="javascript:void(0);"><span class="source">text</span><span class="popup">text</span></a></div>
<div class="rc-box-citations-bot">
<span class="rc-citations-south-west"> </span>
<span class="rc-citations-south-east"> </span>
</div>
</div>
</div>
</div>
</div>
If I modify your xml slightly, and take under the condition that it must belong to to mean that is a descendant of.... then this xpath works
//div[#class='definitionBox'][#id='meaning-1-2']//div[#class='rc-box-citations-body']
The XML is
<?xml version="1.0" encoding="utf-16"?>
<div class="definitionIndent">
<div class="definitionNumber">1.a</div>
<div class="definitionIndent">
<div class="definitionBox" id="meaning-1-1">
<span class="textmedium">
<span class="stampNoBorder">text</span>
<span class="definition">text</span>
</span>
</div>
<div class="definitionBox" id="meaning-1-2">
<div class="rc-box-citations">
<div class="rc-box-citations-top">
<span class="rc-citations-north-west"></span>
<span class="rc-citations-north-east"></span>
</div>
<div class="rc-box-citations-body">
<span class="citation">text</span>
<a class="sourcepop" href="javascript:void(0);">
<span class="source">text</span>
<span class="popup">text</span>
</a>
</div>
<div class="rc-box-citations-bot">
<span class="rc-citations-south-west"></span>
<span class="rc-citations-south-east"></span>
</div>
</div>
</div>
</div>
</div>
The tool I used is XPathVisualizer:

Resources