An easy way to do recursion in cf is to use a custom tag. One of the  
things you will have to do is have your top level be set to a parent  
id that wont get used in any levels below it. I like to set the top  
level to zero or one.
The first time you call your custom tag you just pass the top level  
id you have chosen in as the first id. Then inside of that call the  
tag again passing the parentid. The code is untested but should give  
you a general idea.

Dave

<cf_getmenu ParentItemID=1 level=1>


The code would go something like this:

<cfset level=#Attributes.level# + 1>

<cfquery datasource="#Application.dsn#" name="getCats">
     SELECT ID, CategoryName, ParentItemID
     FROM CategoryTable
     WHERE ParentItemID = #Attributes.ParentItemID#
</cfquery>

<cfoutput query="getCats">
<cfloop from="1" to="#Attributes.level#">-</cfloop>#CategoryName#
</cfoutput>

<cf_getmenu ParentItemID=#getCats.ParentItemID# level=#level#>





On Oct 26, 2005, at 5:15 AM, Stephen Whiteley wrote:

> Hi
>
> I keep returning to this problem in order to build an infinite  
> DHTML menu (a task which has now become a quest and a matter of  
> honour). Does anyone know how to recurse through an adjacency list  
> model table, of the following setup
>
> ID CategoryName ParentItemID
>
> Also, I hear you can use CFTREE format="xml" or format="object" and  
> then use that to make a DHTML menu? anyone have any experience
>
> Muchos Thank You's
>
> Steve
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222390
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to