Created
August 10, 2016 13:46
-
-
Save briancribb/22a7231df98a10fce1e204c85e3d09d4 to your computer and use it in GitHub Desktop.
Makes an unordered list from the direct children of a content item in Mura. The item is selected by passing in its title attribute.
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
<!--- | |
Ex: <cfoutput>#listDirectChildren( 'My Title')#</cfoutput> | |
NOTE: Mura refers to children as "kids" in its internal methods and functions. | |
---> | |
<cffunction name="listDirectChildren"> | |
<cfargument name="parentname" required="true" /> | |
<!--- Local variable for use inside this function. ---> | |
<cfset var local = {} /> | |
<cfset local.str = '' /> | |
<cfset local.cBean = $.getBean('content').loadBy(title=arguments.parentname) /> | |
<cfif local.cBean.exists()> | |
<!--- If we get a bean from the name that was passed in, then we get a kids iterator. ---> | |
<cfset local.itKids = local.cBean.getKidsIterator() /> | |
<cfif local.itKids.hasNext()> | |
<cfsavecontent variable="local.str"> | |
<cfoutput> | |
<!--- Loop through the kids and ouput their titles as an unordered list. ---> | |
<cfloop condition="local.itKids.hasNext()"> | |
<cfset local.itKid = local.itKids.next() /> | |
<li>#local.itKid.get('title')#</li> | |
</cfloop> | |
</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