Created
December 7, 2017 16:19
-
-
Save stevewithington/ba3cb3860b97317d659e396525f606b9 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.
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
<!--- | |
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