Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
I've created a custom tag that recurses over a database to create a breadcrumb trail.The problem I'm encountering is I would really like to be able to pull a list from that tag that it can then be easily manipulated.Below is the custom tag code:

cfquery name=checkParent datasource=#request.siteDSN#
SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
WHERE keywords.keyword = '#attributes.child#'
/cfquery

cfloop query=checkParent

cfquery name=checkNextParent datasource=#request.siteDSN#
SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
WHERE keywords.keyword = '#checkParent.parentName#'
/cfquery

cfoutput

cfif checkNextParent.recordcount NEQ 0
cf_breadcrumbs child=#checkParent.parentName# breadcrumbs=  a href=''#checkParent.ParentTitle#/asiteDomain=#attributes.siteDomain#
/cfif

/cfoutput

/cfloop

cfoutput
#attributes.breadcrumbs#
/cfoutput

Currently the breadcrumbs display directly from the custom tag which works relatively well.Except there are instances when I would really like to have the data placed into a list.Any ideas how I could accomplish this?Any help would be greatly appreciated.

--Anne
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread John Beynon
valuelist() perhaps?

jb.

On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:
 I've created a custom tag that recurses over a database to create a breadcrumb trail.The problem I'm encountering is I would really like to be able to pull a list from that tag that it can then be easily manipulated.Below is the custom tag code:
 
 cfquery name=checkParent datasource=#request.siteDSN#
 SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
 FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
 WHERE keywords.keyword = '#attributes.child#'
 /cfquery
 
 cfloop query=checkParent
 
 cfquery name=checkNextParent datasource=#request.siteDSN#
 SELECT Keywords.KeyID, Keywords.Keyword, Keywords.Title, Keywords.ViewID, Keywords.AppID, Navigation.ParentID, ParentName.Keyword AS ParentName, ParentName.Title AS ParentTitle
 FROM (Navigation AS Parent RIGHT JOIN (Keywords RIGHT JOIN Navigation ON Keywords.KeyID = Navigation.KeyID) ON Parent.NavID = Navigation.ParentID) LEFT JOIN Keywords AS ParentName ON Parent.KeyID = ParentName.KeyID
 WHERE keywords.keyword = '#checkParent.parentName#'
 /cfquery
 
 cfoutput
 
 cfif checkNextParent.recordcount NEQ 0
 cf_breadcrumbs child=#checkParent.parentName# breadcrumbs=  a href=''#checkParent.ParentTitle#/asiteDomain=#attributes.siteDomain#
 /cfif
 
 /cfoutput
 
 /cfloop
 
 cfoutput
 #attributes.breadcrumbs#
 /cfoutput
 
 Currently the breadcrumbs display directly from the custom tag which works relatively well.Except there are instances when I would really like to have the data placed into a list.Any ideas how I could accomplish this?Any help would be greatly appreciated.
 
 --Anne
 

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
I don't think that will work in a recursion judging by what I've read about it.It seems it just takes data from a query column and creates a list out of it. But, that's assuming all of the data needed for the list is there on the first query.Since I'm dealing with a recursion, the query will obtain only one record per recurse of the tag.Granted, I may not fully understand how this tag could be used in my case so if I'm misunderstanding it, please enlighten me. One other issue is that I also need to be able to attain the list from outside the custom tag which may or may not put another snag into this problem.

Thanks,
--Anne

valuelist() perhaps?

jb.

On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Joe Rinehart
Hi Anne,

In your custom tag, you can look at the base tag list with
getBaseTagList() and see if it is its own first base tag.If not,
create a structure called ancestorData, and give it a member called
ancestorList.If it is its own base tag, create a reference to the
structure using ancestorData =
getBaseTagData(cf_breadcrumbs).ancestorData.At the end of your
breadcrumbs tag, pass the structure back to the current page using the
caller scope.

On a side note, this system could be very resource intensive.You may
want to look at ways to have your navigation table track its own
hierarchy, having a column that tracks what generation a child is, and
what its root parent ID is.That way, you can query an entire
breadcrumb in one query by asking for all children of a root parent ID
ordered by their generation.

Disclaimer:There are also many other ways to implement this that are
even less intensive, but require more development that I can't go into
right now because my dev server just came back up.

Cheers,

Joe

- Original Message -
From: Anne Girardeau [EMAIL PROTECTED]
Date: Tue, 24 Aug 2004 10:48:03 -0400
Subject: Re: Creating a List from a Recursion
To: CF-Talk [EMAIL PROTECTED]

I don't think that will work in a recursion judging by what I've read
about it.It seems it just takes data from a query column and creates
a list out of it. But, that's assuming all of the data needed for the
list is there on the first query.Since I'm dealing with a recursion,
the query will obtain only one record per recurse of the tag. 
Granted, I may not fully understand how this tag could be used in my
case so if I'm misunderstanding it, please enlighten me. One other
issue is that I also need to be able to attain the list from outside
the custom tag which may or may not put another snag into this
problem.

 Thanks,
 --Anne

valuelist() perhaps?
 
 jb.
 
 On Tue, 24 Aug 2004 09:53:04 -0400, Anne Girardeau
[EMAIL PROTECTED] wrote:
 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
Hey Joe,

Thanks for your input.Actually I figured something out using session variables and it works amazingly well. The performance of it also isn't too terrible since the most the script should ever recurse would be 5 or 6 times, if that.

I am, however, intrigued by your comment about having the database track its own hierarchy.I tried creating new columns for generation and parent root but got stuck when I was trying to get the path for a 3rd generation crumb with several 2nd generation crumbs that shared the same root, if that makes any sense.In other words, I could get the first and last breadcrumbs without problems but getting the second was a bit difficult without something to tell the system which second generation crumb to use.

The other option you suggested I did play around with but was never able to totally figure it out.I'm assuming it's intended to be utilized in a CF script and I don't have too much experience with CF scripting.

Thanks for your help,
--Anne

Hi Anne,

In your custom tag, you can look at the base tag list with
getBaseTagList() and see if it is its own first base tag.If not,
create a structure called ancestorData, and give it a member called
ancestorList.If it is its own base tag, create a reference to the
structure using ancestorData =
getBaseTagData(cf_breadcrumbs).ancestorData.At the end of your
breadcrumbs tag, pass the structure back to the current page using the
caller scope.

On a side note, this system could be very resource intensive.You may
want to look at ways to have your navigation table track its own
hierarchy, having a column that tracks what generation a child is, and
what its root parent ID is.That way, you can query an entire
breadcrumb in one query by asking for all children of a root parent ID
ordered by their generation.

Disclaimer:There are also many other ways to implement this that are
even less intensive, but require more development that I can't go into
right now because my dev server just came back up.

Cheers,

Joe
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Barney Boisvert
I'd recommend using the request scope, rather than the session scope. 
A breadcrumb display is not bound to a user session in any way, it's
strictly related to the current request.

Joe's suggestion to use the custom tag framework that CF provides is
superior even to that, because it allows multiple invocations of the
tag on a single request to remain totally independant, but that's
probably not much of an issue with breadcrumb generation.

cheers,
barneyb

On Tue, 24 Aug 2004 17:24:01 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:
 Hey Joe,
 
 Thanks for your input.Actually I figured something out using session variables and it works amazingly well. The performance of it also isn't too terrible since the most the script should ever recurse would be 5 or 6 times, if that.
 
 I am, however, intrigued by your comment about having the database track its own hierarchy.I tried creating new columns for generation and parent root but got stuck when I was trying to get the path for a 3rd generation crumb with several 2nd generation crumbs that shared the same root, if that makes any sense.In other words, I could get the first and last breadcrumbs without problems but getting the second was a bit difficult without something to tell the system which second generation crumb to use.
 
 The other option you suggested I did play around with but was never able to totally figure it out.I'm assuming it's intended to be utilized in a CF script and I don't have too much experience with CF scripting.
 
 Thanks for your help,
 --Anne

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




Re: Creating a List from a Recursion

2004-08-24 Thread Anne Girardeau
Thanks for the tip barneyb, I replaced session with request and it still works beautifully.

I agree that it's not much of an issue with breadcrumb generation.I'm never going to need more than one set of breadcrumbs on a requesting page so hopefully I'm pretty safe with what I have.

Thanks again,
--Anne

I'd recommend using the request scope, rather than the session scope. 
A breadcrumb display is not bound to a user session in any way, it's
strictly related to the current request.

Joe's suggestion to use the custom tag framework that CF provides is
superior even to that, because it allows multiple invocations of the
tag on a single request to remain totally independant, but that's
probably not much of an issue with breadcrumb generation.

cheers,
barneyb

On Tue, 24 Aug 2004 17:24:01 -0400, Anne Girardeau [EMAIL PROTECTED] wrote:

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]




RE: Creating a List from a Recursion

2004-08-24 Thread Dennis Powers
 Currently the breadcrumbs display directly from the custom
 tag which works relatively well.Except there are instances
 when I would really like to have the data placed into a list.
 Any ideas how I could accomplish this?

You need to build the list successively with each recursion and then pass it
back the to calling routine.We do this with a breadcrumb tag we wrote for
our applications.

In our case we wanted a list of the ID numbers of the levels that were
recursed.So we created a variable Levellist that gets passed to the
recursive routine as an attribute then in the routine we executed this
command

cfset LevelList = ListPrepend(#Attributes.LevelList#,
#GetLevel.ParentItemID#)

then at the end of the routine we pass it back

cfset Caller.Levellist=LevelList


Best Regards,

Dennis Powers
UXB Internet- A Website Design and Hosting Company
690 Wolcott Road - P.O. Box 6028
Wolcott, CT 06716 tel: (203)879-2844
http://www.uxbinternet.com
http://dennis.uxb.net
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]
 [Donations and Support]