Ah, I think I get you now.

If you simply start with just the parents, and loop through them filling in
the children for each one as you go I think it will work as you want.

Infact, I remember doing something like this a while back... not the exact
same thing, but possibly close enough.
Take a look at http://hybridchill.com/misc/nest/
Code is available at http://hybridchill.com/misc/nest/nest.zip
Doesn't actually use a DB - it constructs the queries manually, but to apply
it to your table you just need to create a second table and move parentId
into that alongside Id as a foreign key, and then join on them.
Looking at it, the code might not be as obvious as it should be, so feel
free to ask questions. :)


On 8/6/07, Bruce Sorge <[EMAIL PROTECTED]> wrote:
>
> I am creating dynamic navigation on the site. So I have a series of
> records
> that build the navigation as well as the site (I am creating a cheesy
> overly
> simple for my own use only CMS). So when I create a new page, the
> information is automatically entered into the databse thus creating the
> site
> pages/navigation/breadcrumb nav. So if I have a parent page called
> Departments, and under it I have Transportation, Transportation will show
> up
> under Departments as a child page (has a dash on the left to indent it and
> show it is a child). I want all of the parent pages to sort in a certain
> order, and if there is a child page, it automatically goes under that
> parent. If I sort the query by ID, I get the proper order, but if a child
> page has a record ID of 20 and it's parent is record ID 15, the child page
> goes under record ID 19 instead of it's parent of 15. If I sort by the
> hiearchy field, then the parent/child relationship works fine, but the
> sorting of the parents is off.
> So I am now thinking of putting a sort order in there and when I create a
> page, I have a select list that I pick the order it is supposed to go in,
> but that is going to be messy since pages can be added after the site is
> done. So if I have a new child page that falls under the parent with an ID
> of say 30, and there are 55 pages, the ID of the new page is going to be
> 56,
> and even though I have a field called parentID and it would have 30 in it,
> I
> would have to do a lot of shuffling around of the sort order.
>
> Hopefully this makes sense?
>
>
>
> Bruce
>
>
> On 8/6/07, Peter Boughton wrote:
> >
> > I'm not sure I understand you, but eitherway it sounds over-complicated.
> >
> > Is there a reason you can't simply create a numerical field to use for
> > ordering, and update the values of that to get things in the right
> > position?
> >
> >
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2902
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6

Reply via email to