Last active
February 16, 2022 16:11
-
-
Save smutek/1eacaee632da2551b8cbb1eba9b543c4 to your computer and use it in GitHub Desktop.
Simple Sage 9 Slider with Slick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@php(the_content()) | |
@if($images) | |
@include('partials/slider') | |
@endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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