Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dreamstarter/11d9c5ec583d90fb0e4e5a34b4e7a363 to your computer and use it in GitHub Desktop.
Save dreamstarter/11d9c5ec583d90fb0e4e5a34b4e7a363 to your computer and use it in GitHub Desktop.
Mura CMS: Bootstrap Carousel Example Using Local Content Index
<!--- BEGIN: Bootstrap Carousel --->
<cfset feed=$.getBean('feed').loadBy(name='Your FeedName Goes Here')>
<cfset iterator=feed.getIterator()>
<cfif iterator.hasNext()>
<div id="myCarousel" class="carousel slide">
<!--- Carousel items --->
<div class="carousel-inner">
<cfset idx = 0>
<cfloop condition="iterator.hasNext()">
<cfset item=iterator.next()>
<cfif listFindNoCase('jpg,jpeg,gif,png', ListLast(item.getImageURL(), '.'))>
<cfset idx++>
<div class="item<cfif idx eq 1> active</cfif>">
<img src="#item.getImageURL(width=1200,height=500)#" alt="#HTMLEditFormat(item.getTitle())#">
<div class="carousel-caption">
<h4><a href="#item.getURL()#">#HTMLEditFormat(item.getTitle())#</a></h4>
#item.getSummary()#
</div>
</div>
</cfif>
</cfloop>
</div>
<cfif idx>
<!--- Carousel nav --->
<cfif idx gt 1>
<a class="left carousel-control" href="##myCarousel" data-slide="prev">&lsaquo;</a>
<a class="right carousel-control" href="##myCarousel" data-slide="next">&rsaquo;</a>
</cfif>
<cfelse>
<div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert">x</button>
<h4>Oh snap!</h4>
Your feed has no items <em>with images</em>.
</div>
</cfif>
</div>
<cfelse>
<div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert">x</button>
<h4>Heads up!</h4>
Your feed has no items.
</div>
</cfif>
<!--- // END: Bootstrap Carousel --->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment