Skip to content

Instantly share code, notes, and snippets.

@smutek
Last active February 16, 2022 16:11
Show Gist options
  • Save smutek/1eacaee632da2551b8cbb1eba9b543c4 to your computer and use it in GitHub Desktop.
Save smutek/1eacaee632da2551b8cbb1eba9b543c4 to your computer and use it in GitHub Desktop.
Simple Sage 9 Slider with Slick
@php(the_content())
@if($images)
@include('partials/slider')
@endif
<?php
namespace App;
/**
* Super Simple Slider
*
* Uses Advanced Custom Fields image gallery field, but this
* can be extended to pretty much anything else.
*
* @param $data
*
* @return mixed
*/
function slider( $data ) {
$images = get_field('images');
if ( $images ) {
$data['images'] = $images;
}
return $data;
}
add_filter( 'sage/template/page/data', 'App\\slider' );
<ul class="list-unstyled slider">
@forelse($images as $image)
<li class="card">
<img class="card-img-top" src="{{$image['url']}}" alt="{{$image['alt']}}">
<div class="card-block">
<h4 class="card-title text-center">{{$image['caption']}}</h4>
</div>
</li>
@empty
<li class="alert alert-danger">No Images</li>
@endforelse
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment