I want to make a slider dynamic in the Php Laravel framework. there is 4 image that is sliding, title and description are fixed on each sliding...
View:-
<div id="slider" class="nivoSlider">
#foreach($sliders as $slider)
<div class="aaa">
<img src="{{ asset('/uploads/')}}/{{$slider->background_image }}" data-thumb="{{ asset('/uploads/')}}/{{$slider->background_image }}" alt="" height="615px" width="1263px">
<div class="pra">
<h1>{{$slider->title}}</h1>
<p>{{$slider->description}}
</p>
<div class="btn-1">
Contact US
</div>
</div>
</div>
#endforeach
`
Controller:-
public function index(){
$sliders=home1::all();
return view('User.userdashboard',compact('sliders'));
}`
Route:-
Route::get('/',['as'=>'construction','uses'=>'User\UserController#index']);
Actual Design of slider:-
<div id="slider" class="nivoSlider">
<div class="aaa">
<img src="images/banner-1.jpg" data-thumb="images/toystory.jpg" alt="" />
</div>
<div class="aaa">
<img src="images/banner-2.jpg" data-thumb="images/up.jpg" alt=""/>
<div class="pra">
<h1> The Best Business Support</h1>
<p>
Preparing your money is a daunting challenge for today's investors.</p>
<div class="btn-1">
Contact US
</div>
</div>
</div>
<div class="aaa">
<img src="images/banner-3.jpg" data-thumb="images/walle.jpg" alt="" data-transition="slideInLeft" />
</div>
<div class="aaa">
<img src="images/banner-4.jpg" data-thumb="images/nemo.jpg" alt="" />
</div>
</div>
`
I don't understand where to start the foreach loop so that only images are slide
when I add another data from admin panel with column 'image','title', 'description'
the images are showing perfectly but title and description are overwrite
please help me in sorting out this problem
actually in your controller you get a collection under $sliders variable. $sliders=home1::all();.
You said that your home1 Model have some columns like 'image', 'title', 'description'.
So in your blade file you are getting $sliders because the compact('slides') instruction.
In that way your should be able to loop through $slidersjust like as you are referencing in your question:
#foreach ($sliders as $slider)
<div class="aaa">
<img src="{{ asset('/uploads/')}}/{{$slider->background_image }}"
data-thumb="{{ asset('/uploads/')}}/{{$slider->background_image }}"
alt="" height="615px" width="1263px">
<div class="pra">
<h1>{{$slider->title}}</h1>
<p>{{$slider->description}}</p>
<div class="btn-1">
Contact US
</div>
</div>
</div>
#endforeach
Here $slider contains each object from $sliders collection so you should see its own title and description alongside the image field.
You could test what $sliderscontains by dumping the collection in your blade file, using {{ dd($sliders) }}.
Regards.
Related
I am trying to display the single image in the slider, but whenever the user will click on this then it's open a popup in data-src="multiple-images-here" where I am running the slider. But the main issue is with the single image display in for loop. It displays all the available images in the loop. Please suggest me the best solution for this.
Here is my index.blade.php file where I am trying to display the slider using this code.
<div class="container-fluid margin-gallery d-lg-block d-block position-relative">
<div class="row">
<div class="col-lg-12 p-0">
<div class="demo-gallery">
#php
if($propertys->propertyImage!=null){
$images = json_decode($propertys->propertyImage->image_path, true);
}
else{
$images=null;
}
#endphp
<?php
$images_prop = collect($images['property_images']);
?>
<ul id="lightgallery">
#if($images['property_images']!=null)
#forelse($images_prop as $img)
<li class="sizing-li position-relative" data-src="{{ asset($img) }}">
<a href="javascript:void()">
<img class="img-responsive" src="{{ asset($img) }}" style="width:929px; height:495px;">
</a>
</li>
#empty
#endforelse
#endif
</ul>
</div>
</div>
</div>
</div>
I want to display the first image from for loop here
<img class="img-responsive" src="{{ asset($img) }}" style="width:929px; height:495px;">
You can pass ->first() function to get only 1 images, It will show you only the first item from your data in database.
Let’s say I have a foreach post that shows the last 5 posts, and I would like to position them as the boostrap featurette (with text and image changing To left and right side: example: https://getbootstrap.com/docs/4.0/examples/carousel/
i tried but it's not display well and not responsive. so if you have time, pls help.
<div class="container">
#foreach($posts as $post)
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading">{{ $post->title }}</h2>
<p class="lead">{{ $post->title }}</p>
</div>
<div class="col-md-5">
<img class="featurette-image img-fluid mx-auto" src="{{ asset('assets/img/laptop-1385702_1920.jpg') }}" alt="Generic placeholder image">
</div>
</div>
<br>
#endforeach
</div>
--> not working : result
**this is my home page ** i am showing data coming from mysql to card but is have same tag color i.e class="tag tag-pill tag-danger"
i am using ng-class={{hos.class}} /*class is a coloumn in table */
<div class="col-md-5" ng-repeat="hos in ho">
<div class="col-md-6">
<div class="card"> <img class="img-fluid" ng-src="{{hos.img}}" alt="">
<div class="card-img-overlay"> <span ng-class=" ">{{hos.tag}}</span> </div>
<div class="card-block">
<div class="news-title">
<h2 class=" title-small">{{hos.topic}}</h2>
</div>
<p class="card-text"><small class="text-time"><em>{{hos.time}}</em></small></p>
</div>
</div>
</div>
</div>
try ng-class="hos.tag" or class="{{hos.tag}}"
You are using ng-class incorrectly: its expression comprises of an object where each property is a class and the value is an expression to evaluate to conditionally apply that class when truth.
For example ng-class="{'active': button.active}"
Hopefully, this fiddle will help: jsFiddle
I have the following code:
<div class="container-fluid>
{files}
<div class="media">
<div class="media-left">
<img src="<?php echo base_url('files/{filename}'); ?>" alt="afbeelding" class="media-object" style="width:200px">
</div>
<div class="media-body">
<h4 class="media-heading">{title}</h4>
<p>{text}</p>
</div>
</div>
<br>
{/files}
</div>
The current result is just the title and text being shown, without the image. When I remove the whole div with class "media-body", the image shows. I think my code is structured right, I followed the w3-schools example. How can I get both the image and text to show up in the bootstrap media format?
Missing "
Change from
<div class="container-fluid>
to
<div class="container-fluid">
i am new to wordress
i want to make image gallery from basic bootstrap template
i have this template for example:
<div class="row portfolio-images">
<div class="col-md-3">
<img src="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
</div>
i want to know how to create image database or gallery in wordpress in the panel
and get the images url in an array and do something like this:
<div class="row portfolio-images">
<?php
for(the array){ ?>
<div class="col-md-3">
<img src="<?php echo image url ?> ">
<a class="title" ><?php echo image title ?></a>
</div>
<?php }?>
</div>
because im lost right now and i need some guidence
There are various plugins that you can use to generate the gallery. If you need to generate one without plugin then you can define a custom post type and then add images post on the relevant post type, which then can be listed on the required page.
Usually I use ACF plugin to generate custom field and then list it on the page. You can check it more here: http://www.advancedcustomfields.com/resources/gallery/