The categoryAssociation is usually used to select categories. I ran into a problem with that because it doesn’t natively restrict the selection to a single category, which I needed. So, after some digging, I found that using a combination of the functions included in application.factory.ocategory got me the result I was looking for.
Specifically, I had a category called calendar under root which I knew would always be there. I needed a list of the categories under calendar. Here’s what I did:
Throw this code inside the select tag and you get this:
<label for="filterBy"><b>Filter By:</b>
<select name="filterBy">
<option value="" <cfif len(trim(stObj.filterBy)) eq 0>selected</cfif>>No Filter</option>
<cfset qCalCats = application.factory.oTree.getDescendants(application.factory.ocategory.getCategoryID('calendar', application.catid.root))>
<cfloop from="1" to="#qCalCats.recordcount#" index="i">
<cfset pre = " ">
<cfif qCalCats.nLevel[i] gt 2>
<cfloop from="3" to="#qCalCats.nLevel[i]#" index="j">
<cfset pre = pre & "- ">
</cfloop>
</cfif>
<option value="#qCalCats.objectName[i]#" <cfif stObj.filterBy eq qCalCats.objectName[i]>selected</cfif>>#pre##qCalCats.objectName[i]#</option>
</cfloop>
</select><br>
</label>

Related Articles
No user responded in this post
Leave A Reply