Skip to content

Instantly share code, notes, and snippets.

@mattlevine
Created June 7, 2018 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattlevine/0c1abc010b2d43f2a135d63c811e7659 to your computer and use it in GitHub Desktop.
Save mattlevine/0c1abc010b2d43f2a135d63c811e7659 to your computer and use it in GitHub Desktop.
Example of a custom Mura category summary display object that shows the parent name
<cfparam name="objectparams" default="#structNew()#">
<cfparam name="objectparams.displayRSS" default="false">
<cfparam name="useRss" default="#objectparams.displayRSS#">
<cfif not isValid('uuid',arguments.objectid)>
<cfset crumbIterator=$.content().getCrumbIterator()>
<cfloop condition="crumbIterator.hasNext()">
<cfset crumb=crumbIterator.next()>
<cfif listFindNoCase('Folder',crumb.getType())>
<cfset arguments.objectid=crumb.getContentID()>
<cfbreak>
</cfif>
</cfloop>
</cfif>
<cfset section=$.getBean('content').loadBy(contentid=arguments.objectid)>
<cfif section.exists()>
<cfsilent>
<cfif section.gettype() neq "Calendar">
<cfset today=now() />
<cfelse>
<cfset today=createDate($.event('year'),$.event('month'),1) />
</cfif>
<!--- Set categorypathid a categoryid to pull only categories under it. --->
<cfset rs=section.getKidsCategoryQuery(categorypathid='')>
<cfset viewAllURL="#$.siteConfig('context')##getURLStem($.event('siteID'),section.getFilename())#">
<cfif len($.event('relatedID'))>
<cfset viewAllURL=viewAllURL & "?relatedID=#HTMLEditFormat($.event('relatedID'))#">
</cfif>
</cfsilent>
<cfif rs.recordcount>
<cfoutput>
<div class="svCatSummary mura-category-summary #this.navWrapperClass#">
<cfif len(this.navCategoryWrapperBodyClass)><div class="#this.navCategoryWrapperBodyClass#"></cfif>
<#$.getHeaderTag('subHead1')#>#$.rbKey('list.categories')#</#$.getHeaderTag('subHead1')#>
<ul class="#this.ulTopClass#"></cfoutput>
<cfoutput query="rs" group="parentname">
<li><cfif len(rs.parentname)>#rs.parentname# <ul></cfif>
<cfoutput>
<cfsilent>
<cfif len(rs.filename)>
<cfset categoryURL="#$.siteConfig('context')##getURLStem($.event('siteID'),section.getFilename() & '/category/' & rs.filename)#">
<cfif len($.event('relatedID'))>
<cfset categoryURL=categoryURL & "?relatedID=#HTMLEditFormat($.event('relatedID'))#">
</cfif>
<cfelse>
<cfset categoryURL="#$.siteConfig('context')##getURLStem($.event('siteID'),section.getFilename())#?categoryID=#rs.categoryID#">
<cfif len($.event('relatedID'))>
<cfset categoryURL=categoryURL & "&relatedID=#HTMLEditFormat($.event('relatedID'))#">
</cfif>
</cfif>
</cfsilent>
<cfset class=iif(rs.currentrow eq 1,de('first'),de(''))>
<li class="#this.navLiClass#<cfif len(class)> #class#</cfif><cfif listFind($.event('categoryID'),rs.categoryID)> #this.liCurrentClass#</cfif>">
<a <cfif listFind($.event('categoryID'),rs.categoryID)>class="#this.aCurrentClass#"<cfelse>class="#this.aNotCurrentClass#"</cfif> href="#categoryURL#">#rs.name# <span>(#rs.count#)</span></a>
<cfif useRss>
<a class="rss" href="#$.globalConfig('context')#/index.cfm/feed/v1/?siteid=#$.event('siteID')#&contentID=#section.getContentID()#&categoryID=#rs.categoryID#"
<cfif listFind($.event('categoryID'),rs.categoryID)>class="#this.aCurrentClass#"<cfelse>class="#this.aNotCurrentClass#"</cfif>>RSS</a>
</cfif>
</li>
</cfoutput>
<cfif len(rs.parentname)></ul></cfif>
</li>
</cfoutput>
<cfoutput>
<li class="last #this.navLiClass#"><a href="#viewAllURL#" <cfif not len($.event('categoryID'))>class="#this.aCurrentClass#"<cfelse>class="#this.aNotCurrentClass#"</cfif>>#$.rbKey('list.viewall')#</a><cfif useRss><a class="rss" href="#$.globalConfig('context')#/index.cfm/feed/v1/?siteid=#$.event('siteID')#&contentID=#rsSection.contentid#">RSS</a></cfif></li>
</ul>
</div>
<cfif len(this.navCategoryWrapperBodyClass)></div></cfif>
</cfoutput>
</cfif>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment