Looked into all of those links, however database re-write is not possible and so would be difficult to implement, but thanks for the info.
I like the sound of the custom functions but can't see the wood for the trees on where to begin.
Any suggestions of where I could find some recursive udf's?
Thanks for the help,
Dave
At 13:07 7/18/2003 +0100, you wrote:
Dave, did you get anywhere with this?
Ade
-----Original Message----- From: Adrian Lynch [mailto:[EMAIL PROTECTED] Sent: 17 July 2003 11:02 To: '[EMAIL PROTECTED]' Subject: RE: [ cf-dev ] Selective recurse - help!!
I've been doing the same recently.
These might be of interest is you find the recursive approach a little sluggish...
http://www.dbmsmag.com/9604d06.html http://www.dbmsmag.com/9603d06.html
They are about something called the "preorder tree-traversal algorithm". Which I think is a nice alternative if a little bit of a mind f**k compared to the parent/child way.
I did have links to easier to read articles but I can't seem to find them.
Or there is this method...
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7321&lng WId=4
As for displaying the menu, why not try and break it down into smaller bits.
Write a function that displays/or returns the ids that need to be diplayed, for a given item id. For an id of 0, all the children of 0 are returned. [A]
Write another function that looks up an items parent. [B]
Then maybe create an array that holds the menu item ids that need to be opened. It will always contain 0, to show the top level items. You could populate this array by doing a lookup using [B]. Then as [A] goes through all the items it needs to you can check if the id is in the array and call the function[A] again with that id as the argument.
If all this seems like it is running slowly, pull back all the data and use QofQ for all the recursive/parent lookups.
What do you reckon? I hope that made sense.
Ade
-----Original Message----- From: Dave Phipps [mailto:[EMAIL PROTECTED] Sent: 17 July 2003 10:29 To: ColdFusion User group Subject: [ cf-dev ] Selective recurse - help!!
Hi,
I am using a recursive tag to generate some navigation links. The table structure for the menus is set up in a parent/child relationship with menus have a parentmenuid equal to the parent menuid or 0 if it is a parent. The recursive tag grabs the menu then checks for children then calls itself to check if each child has any children etc.
We have one section of the site with a large number of menus and it looks pretty ugly. What I want to do is only show the children of the select parent.
The url to view is: http://new.abingdon.org.uk/index.cfm?fuseaction=academic.content&cmid=72 The site is not yet live but needs to be sorted asap.
What I want to happen with the menu: When you arrive to the Academic section you should just see the top level menus (parents) then clicking on Departments will move to another page with the departments listed. When a specific department is clicked then the children of this department will be seen.
If anyone could spare a few moments to take a look and see if there is a way to alter the tag to do the above that would be great. Is there a better way to do this navigation?
The code for the tag is below: <cfsilent> <cfparam name="theid" default="0"> <cfparam name="mode" default="outline"> <cfparam name="indent" default="0"> <cfparam name="attributes.circuitname" default=""> <cfif IsDefined("attributes.indent")> <cfset indent = attributes.indent> </cfif> <cfif IsDefined("attributes.theid")> <cfset theID = attributes.theid> </cfif> <cfif IsDefined("attributes.mode")> <cfset mode = attributes.mode> </cfif> <cfparam name="attributes.showAll" default="false"> <cfquery datasource="#request.dsn#" name="getMenus" dbtype="ODBC"> SELECT circuits.circuitname, menus.menuid, menus.circuitid, menus.menuname, menus.parentmenuid, menus.displayorder, contentManager.cmid FROM circuits, menus, contentManager, content WHERE parentmenuid = #theid# AND content.onMenu = 1 <cfif attributes.showAll EQ false>AND content.isApproved = 1</cfif> AND contentManager.contentid = content.contentid AND contentManager.menuid = menus.menuid AND circuits.circuitid = menus.circuitid AND circuits.circuitname = '#attributes.circuitname#' ORDER BY menus.displayorder, menuid, parentmenuid </cfquery> </cfsilent>
<cfloop query="getMenus"> <cfset thisid = getMenus.cmid> <cfoutput> <span class="navbar" style="margin-left:#indent#px;"> <cfif attributes.cmid EQ thisid OR (IsDefined("caller.getFirstPage.recordcount") AND caller.getFirstPage.cmid EQ thisid)> <img src="images/site_gfx/arrow_blue.gif" border="0" name="section#menuid#"><span style="color:##7C8AA2;">#menuname#</span> <cfelse> <a href="#request.self#?fuseaction=#getMenus.circuitname#.content&cmid=#cmid#" onMouseOut="MM_swapImgRestore(); self.status=''; return true;" onMouseOver="MM_swapImage('section#menuid#','','images/site_gfx/arrow_red.gi f',1); self.status='#Replace(menuname, "'", "", "ALL")#'; return true;"><img src="images/site_gfx/arrow_black.gif" border="0" name="section#menuid#">#menuname#</a> </cfif> </span><br> </cfoutput> <cfquery datasource="#request.dsn#" cachedwithin="#CreateTimeSpan(0,0,0,2)#" name="checkForChild" dbtype="ODBC"> SELECT menuid FROM menus WHERE parentmenuid = #getMenus.menuid# </cfquery>
<cfif checkForChild.RecordCount gt 0> <cfset nextindent = indent + 10> <cfif attributes.showAll EQ true> <cfset attributes.showAll = true> </cfif> <cf_buildtree theid = "#getMenus.menuid#" mode = "#mode#" indent="#nextindent#" circuitname="#attributes.circuitname#" cmid="#attributes.cmid#" showAll="#attributes.showAll#"> </cfif> </cfloop>
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
