Last active
October 5, 2018 17:56
-
-
Save stevewithington/2b3016f0d0e3836db298 to your computer and use it in GitHub Desktop.
Mura CMS: How to loop over categories and output any categorized content.
This file contains hidden or 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
<cfoutput> | |
<cfset cats = 'Weather,Local News,Arts & Culture' /> | |
<ul> | |
<cfloop array="#ListToArray(cats)#" index="c"> | |
<li> | |
<h3>#HTMLEditFormat(c)#</h3> | |
<cfscript> | |
catBean = $.getBean('category').loadBy(name=c, siteid=$.event('siteid')); | |
feed = $.getBean('feed'); | |
feed.setCategoryID(catBean.getCategoryID()); | |
</cfscript> | |
<cfif catBean.exists() and feed.getIterator().getRecordcount()> | |
<cfset it = feed.getIterator() /> | |
<ul> | |
<cfloop condition="#it.hasNext()#"> | |
<cfset item = it.next() /> | |
<li> | |
<a href="#item.getURL()#"> | |
#HTMLEditFormat(item.getMenuTitle())# | |
</a> | |
</li> | |
</cfloop> | |
</ul> | |
<cfelse> | |
<!--- either the cateogry doesn't exist, or there's no records ---> | |
</cfif> | |
</li> | |
</cfloop> | |
</ul> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment