Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bowler865/674708151a4c0742c19e518c6a32bb30 to your computer and use it in GitHub Desktop.
Save bowler865/674708151a4c0742c19e518c6a32bb30 to your computer and use it in GitHub Desktop.
Mura CMS: How to create custom navigation with permissions applied, based on a contentID and its children.
<!---
Place this function in your Site or Theme contentRenderer.cfc
Invoke by calling `$.dspDescendants()`
--->
<cffunction name="dspDescendants">
<cfargument name="contentid" type="string" default="#$.content('contentid')#" />
<cfset var local = {} />
<cfset local.cBean = $.getBean('content').loadBy(contentid=arguments.contentid) />
<cfsavecontent variable="local.str">
<cfoutput>
<cfif local.cBean.exists()>
<cfset local.it = local.cBean.getKidsIterator(applypermfilter=true) />
<cfif local.it.hasNext()>
<ul>
<cfloop condition="local.it.hasNext()">
<cfset local.item = local.it.next() />
<li>
<a href="#local.item.get('url')#">
#esapiEncode('html', local.item.get('title'))#
</a>
<!--- other generations of descendants --->
<cfif local.item.getKidsQuery(applypermfilter=true).recordcount>
#dspDescendants(contentid=local.item.get('contentid'))#
</cfif>
</li>
</cfloop>
</ul>
<cfelse>
<div class="alert alert-danger">
Unauthorized to view these protected files.
</div>
</cfif>
<cfelse>
<div class="alert alert-warning">
ContentID does not exist.
</div>
</cfif>
</cfoutput>
</cfsavecontent>
<cfreturn local.str />
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment