I have a custom tag (code below) that I am calling upon itself to grab all of the 
departments in the db and building lists such as:

Men's Clothing
Men's Clothing/Shirts
Men's Clothing/Shirts/Long Sleeve
Men's Clothing/Shirts/ShortSleeve
Men's Clothing/Pants
Women's Clothing
Women's Clothing/Shirts
ect..

The problem with this tag is that the VERY LAST output doubles ... so in the example 
above Women's Clothing/Shirts would be listed twice (if it were the last one)  It is 
always the last record.  

Can anyone see where the problem lies?

Sorry for the looong code but it is the only way to figure this one out.

============ Code ====================

<cfif IsDefined("request.catalog_list") Is "No">
 <cfset request.catalog_list = ArrayNew(1)>
</cfif>

<cfparam name="attributes.table" default="#prefs.department_table#">

<!--- this is the list that we're building.  Prefixing it with 'request' means that 
any custom tag at any level of execution has access to it.  Think of it as a temporary 
application variable. --->
<cfparam name="request.catalog_list" default=""> 

<!--- this is the value each instance of this custom tag will use to decide what 
elements it's looking for out of the database.  The default value is 'index' since 
that's your designation for the top of the catalog tree. --->
<cfparam name="attributes.owner" default="#prefs.indexid#">

<!--- this is the value each instance of this custom tag will preface values it adds 
to the listing with. Because the database only contains each item's immediate 
parent/child value, we have to pass this forward. --->
<cfparam name="attributes.path" default="">

<!--- go get the children for the base owner value we're supposed to be looking for 
--->
<cfquery datasource="#prefs.dsn#" name="getChildren">
 SELECT f.owner, f.sub_object, d.id, d.title
 FROM #prefs.fusion_table# f, #attributes.table# d
 WHERE f.sub_object = d.id
 AND f.owner = '#attributes.owner#'
 AND f.type = 'department'
 ORDER BY d.title, f.sub_object
</cfquery>

<!--- Loop over the children of the main owner value.  Our one and only loop. --->
<cfloop query="getChildren">

 <cfparam name="request.count" default="0">
 <cfset request.count = request.count + 1>
 
 <!--- add the path from the index to this location in the tree in front of the name 
of this sub-object --->
 <cfset variables.thisitempath = "#attributes.path#/#getChildren.title#">
 <cfset request.catalog_list[request.count] = StructNew()>
 <cfset request.catalog_list[request.count].tree = variables.thisitempath>
 <cfset request.catalog_list[request.count].id = getChildren.sub_object>
 <!--- Add an item to our list of catalog departments --->
 <cfset temp = ArrayAppend(request.catalog_list, request.catalog_list[request.count])>
    <!--- call this file again, but this time tell it to take a look at the next level 
down.  if there's anything under this department, it will get added to the tree in 
sequence. --->
 <cf_catdump owner="#sub_object#" path="#variables.thisitempath#">

</cfloop>


Thanks In Advance!
Paul Giesenhagen
QuillDesign

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to