2016-04-05 16:38:00 +00:00
|
|
|
<?php
|
|
|
|
// -------------------------------------------
|
|
|
|
// kirby snippet GENERAL
|
|
|
|
// Title: plg-carousel
|
|
|
|
// funct: twitter bootstap carousel for photos in carousel subpage (folder)
|
|
|
|
// modified for bootstrap 4 !
|
|
|
|
|
|
|
|
// copyright: Jannik Beyerstedt | http://jannikbeyerstedt.de | code@jannikbeyerstedt.de
|
|
|
|
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
|
|
|
|
|
|
|
|
// usage:
|
|
|
|
// snippet('plg-carousel', array('currentPage'=>$page,
|
|
|
|
// 'preNormal'=>'optional html to add before carousel',
|
|
|
|
// 'preAlt'=>'html if snippet is not displayed (for other styles)'))
|
|
|
|
|
|
|
|
// and set these constants in config.php:
|
|
|
|
//c::set('plg_carousel.sort', 'sort'); // sortBy parameter: sort, title, etc.
|
|
|
|
//c::set('plg_carousel.dir', 'asc'); // sortBy direction: asc, desc
|
|
|
|
// -------------------------------------------
|
|
|
|
|
|
|
|
// display carousel only if there are images
|
|
|
|
$carouselFolder = $currentPage->children()->find('carousel');
|
|
|
|
if (!isset($preNormal)) {$preNormal="";}
|
|
|
|
if (!isset($preAlt)) {$preAlt="";}
|
|
|
|
$sort = c::get('plg_carousel.sort', 'title');
|
|
|
|
$sdir = c::get('plg_carousel.dir', 'desc');
|
|
|
|
|
|
|
|
// if folder exists
|
|
|
|
if (!(false==$carouselFolder) && ($carouselFolder->hasImages())) : echo $preNormal
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div id="myCarousel" class="carousel slide" data-ride="carousel">
|
|
|
|
|
|
|
|
<!-- Indicators -->
|
|
|
|
<ol class="carousel-indicators">
|
|
|
|
<?php $n=-1; foreach($carouselFolder->images()->sortBy($sort, $sdir) as $image): $n++; ?>
|
|
|
|
<li data-target="#myCarousel" data-slide-to="<?php echo $n ?>" class="<?php if($n==0) echo ' active' ?>"></li>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<div class="carousel-inner" role="listbox">
|
|
|
|
<?php $n=-1; foreach($carouselFolder->images()->sortBy($sort, $sdir) as $image): $n++; ?>
|
|
|
|
<div class="carousel-item<?php if($n==0) echo ' active' ?>">
|
|
|
|
<img src="<?php echo $image->url() ?>" alt="<?php echo $image->title()->html() ?>" />
|
|
|
|
<div class="carousel-caption">
|
|
|
|
<h3><?php echo $image->heading()->kirbytext() ?></h3>
|
|
|
|
<?php echo $image->caption()->kirbytext() ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</div>
|
2017-08-18 23:35:03 +00:00
|
|
|
<a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
|
|
|
|
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
|
|
<span class="sr-only">Previous</span>
|
|
|
|
</a>
|
|
|
|
<a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
|
|
|
|
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
|
|
<span class="sr-only">Next</span>
|
|
|
|
</a>
|
2016-04-05 16:38:00 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php else : echo $preAlt ?>
|
|
|
|
|
|
|
|
<?php endif ?>
|