Skip to content

Instantly share code, notes, and snippets.

@ronnieduke
Created June 24, 2014 16:41
Show Gist options
  • Save ronnieduke/fcf64d2b4cac40db0303 to your computer and use it in GitHub Desktop.
Save ronnieduke/fcf64d2b4cac40db0303 to your computer and use it in GitHub Desktop.
Use the Mura Iterator with a custom query
<cfquery name="rsExample">
SELECT content,siteID
FROM tcontent
WHERE .....
</cfquery>
<cfset it=application.serviceFactory.getBean("contentIterator")>
<cfset it.setQuery(rsExample)/>
<!--- Now Iterate and pull attributes that aren't in the query --->
<cfloop condition="it.hasNext()">
<cfset item=it.next()>
<cfoutput>
#it.currentIndex()#: #item.getMenutitle()# - #item.getCustomVar()#</br>
</cfoutput>
</cfloop>
<!--- You can even set items in your iterator with new values --->
<cfloop condition="it.hasNext()">
<cfscript>
item=it.next();
item.setIsNav(0); // turn off navigation
item.save() // save the content bean
</cfscript>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment