Created
August 17, 2014 10:52
-
-
Save patkon/91e8802b41720a66d6e1 to your computer and use it in GitHub Desktop.
Create Twitter Bootstrap Carousel in flatCore.
This file contains 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 | |
/** | |
* Create Twitter Bootstrap Carousel in flatCore | |
* Filter uploaded images from "content/images/.." by a prefix | |
* example: [plugin=bs-carousel.php]prefix=slider-[/plugin] | |
* | |
* Requirement: flatCore Template which contains Bootstrap and carousel.js | |
* http://getbootstrap.com/javascript/#carousel | |
* License: GNU General Public License | |
* copyright (c) 2014, Patrick Konstandin | |
*/ | |
unset($slides); | |
$slides = glob("content/images/$prefix*.jpg"); | |
$cnt_slides = count($slides); | |
for($i=0;$i<$cnt_slides;$i++) { | |
unset($active_item); | |
if($i==0) { $active_item = 'active'; } | |
$carousel_imgs_str .= ' | |
<div class="item '.$active_item.'"> | |
<img src="'.$slides[$i].'" alt=""> | |
</div>'; | |
} | |
echo '<div id="myCarousel" class="carousel slide" data-ride="carousel">';; | |
echo '<div class="carousel-inner">'; | |
echo "$carousel_imgs_str"; | |
echo '</div>'; // carousel-inner | |
echo '<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> | |
<span class="glyphicon glyphicon-chevron-left"></span> | |
</a>'; | |
echo '<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> | |
<span class="glyphicon glyphicon-chevron-right"></span> | |
</a>'; | |
echo '</div>'; // #myCarousel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment