Last active
September 23, 2020 08:26
-
-
Save stevewithington/77569dca7ac99595d3d9 to your computer and use it in GitHub Desktop.
Mura CMS: A simple method to output the children, grandchildren, great-grandchildren, etc. of a content item based on the parent's contentid.
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
<!--- | |
This is an uber simple method to output children, grandchildren, etc. based on the parent's contentid | |
If you're looking for an easy way to output a child nav, you could also just use Mura's baked-in $.dspNestedNav(contentid) method. | |
See the file located under /requirements/mura/content/contentRenderer.cfc for details. | |
---> | |
<cffunction name="dspDecendants"> | |
<cfargument name="contentid" required="true" /> | |
<cfset var local = {} /> | |
<cfset local.str = '' /> | |
<cfset local.cBean = $.getBean('content').loadBy(contentid=arguments.contentid) /> | |
<cfif local.cBean.exists()> | |
<cfset local.itKids = local.cBean.getKidsIterator() /> | |
<cfif local.itKids.hasNext()> | |
<cfsavecontent variable="local.str"> | |
<cfoutput> | |
<ul> | |
<cfloop condition="local.itKids.hasNext()"> | |
<cfset local.itKid = local.itKids.next() /> | |
<li> | |
#local.itKid.get('menuTitle')# | |
<!--- grandkids ---> | |
#dspDecendants(contentid=local.itKid.get('contentid'))# | |
</li> | |
</cfloop> | |
</ul> | |
</cfoutput> | |
</cfsavecontent> | |
</cfif> | |
</cfif> | |
<cfreturn local.str /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment