Last active
January 3, 2016 17:39
-
-
Save modmedia/8497315 to your computer and use it in GitHub Desktop.
Reset the Mura iterator to output content multiple times
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
<!--- Sometimes you need to output the contents of an iterator multiple times. For example, for a slider with navigation, you may want to output the links as an unordered list and the images as divs ---> | |
<cfoutput> | |
<cfset feed=$.getBean("feed").loadBy(name="Feed Name",siteID=$.event("siteid"))> | |
<cfset iterator=feed.getIterator()> | |
<cfif iterator.hasNext()> | |
<ul> | |
<!--- The list ---> | |
<cfloop condition="iterator.hasNext()"> | |
<cfset item=iterator.next()> | |
<li><a href="##$.createCSSid(item.getTitle())#">#item.getTitle()#</li> | |
</cfloop> | |
</ul> | |
<!--- Start the iterator over again ---> | |
<cfset iterator.reset()> | |
<!--- The content ---> | |
<cfloop condition="iterator.hasNext()"> | |
<cfset item=iterator.next()> | |
<div id="##$.createCSSid(item.getTitle())#">#item.getBody()#</div> | |
</cfloop> | |
</cfif> | |
</cfoutput> |
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
<!--- The list ---> | |
<ul> | |
<li><a href="##item1">Item 1</a></li> | |
<li><a href="##item2">Item 2</a></li> | |
<li><a href="##item3">Item 3</a></li> | |
</ul> | |
<!--- The content ---> | |
<div id="item1"> | |
Content for Item 1 | |
</div> | |
<div id="item2"> | |
Content for Item 2 | |
</div> | |
<div id="item3"> | |
Content for Item 3 | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment