with CF5, so no CFC's then, but I had a single column for parenthood to
keep track of what the parent was, if no parent then that value was 0.
Then to output I used a recursively called include file to loop through
the data. The file below is my categoryloop.cfm file, this goes through
and gets all category levels, and orders them.
<cfparam name="i" default="1">
<cfparam name="k" default="1">
<cfoutput query="GetLevel#i#" group="ID">
<cfset i = i + 1>
<!--- Output category information here --->
<cfquery name="GetLevel#i#" dbtype="dynamic"
connectstring="#request.DBConnectString#">
SELECT ID, CategoryName, SubCategoryOf, CategoryOrder
FROM Category
WHERE SubCategoryOf = #ID#
ORDER BY CategoryOrder
</cfquery>
<cfif Evaluate("GetLevel" & i & ".RecordCount")>
<cfset k = k + 1>
<cfinclude template="categoryloop.cfm">
</cfif>
</cfoutput>
<cfset k = k - 1>
Bernd VanSkiver
[EMAIL PROTECTED]
801.520.5957
-----Original Message-----
From: Deanna Schneider [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 6:25 AM
To: CF-Talk
Subject: SOT: alphabetizing nested sets
So, I'm messing around with nested sets for dealing with tree data. But,
I've come across a snag. It would appear that you can't alphabetize the
children at the same level, at least I haven't figured out how to do it.
Does anyone have a solution for that?
Note: I'm using a modified version of the cfc code from a CFDJ article
on the topic. Table structure like so:
categoryid category lft rgt
1 parent 1 1 6
2 child of parent 1 2 3
3 A second child 4 5
To return all nodes, you run a query like so:
SELECT child.category, COUNT(child.lft) AS lvl, child.lft, child.rgt,
child.categoryid FROM category parent, category child WHERE child.lft
BETWEEN parent.lft AND parent.rgt GROUP BY child.lft, child.rgt,
child.category, child.categoryid ORDER BY child.lft
This results in
Parent 1
--child of parent 1
--a second child
When what I'd like is:
Parent 1
--a second child
--child of parent 1
Thoughts? Elegant solutions?
--
Deanna Schneider
UWEX-Cooperative Extension
Interactive Media Developer
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

