symfony
symfony forum
Home » development » Feature requests » Nested Set
Nested Set [message #1850] Wed, 18 January 2006 12:49 Go to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
I was just wondering if symfony included a class to easily manage a nested set, i think i came across one when i first downloaded the code but cannot seem to find it again anywhere. If there is a class available for this, is there any form of documentation / usage examples to be found anywhere, if there is not currently support ffor this, then are there any suggestions on how best to perform this without using the PEAR Nestedset class which will undermine the propel/creole component of symfony, and are there plans to include this in future releases?

Many thanks
Re: Nested Set [message #2057 is a reply to message #1850 ] Tue, 24 January 2006 16:50 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
I cannot seem to find a class for managing nested sets and if there is no class available then i'd like to write one based upon similiar functionailty as outlined in the following article:

http://www.edutech.ch/contribution/nstrees/index.php

This seems fairly comprehensive and intuitive, i'm unsure if there are any other approaches other than PEAR's Nested Set.

With regards to the best way to design this class, i thought that it might be a good idea if it is considered at the model level of the framework. I am not sure whether this would be the best way or whether it would be possible, however I am suggesting the following:

In the schema.xml file you can identfy the table as a nested set (in a similiar way you can identify i18n tables). When the ORM is created, it still creates the same BaseArticle class with all the standard DA functionality as before, but with extended attributes and methods specific for nested set manipulation. This would then easily allow us to use this functionality within our actions and inline with using propel without having to rely on other DA protocols or direct access to the DB itself (as would be the case with using PEAR's package, this could be a limitation for those who don't want to use propel, but then they could always use PEAR's Nested Set I suppose).

Does anybody have any other suggestions / alternatives, or is it currently available somewhere within Symfony? Also, if this was deemed a good solution and i contributed the extended class functionality, would this be something that you would consider integrating into the framework? Further development would also allow the new admin generator to generate specific actions to manipulate the nested set, thus also automating this in the back office generation.

Thanks

Re: Nested Set [message #4594 is a reply to message #2057 ] Mon, 03 April 2006 19:01 Go to previous messageGo to next message
nightfreak  is currently offline nightfreak
Messages: 36
Registered: November 2005
Member

Hi,

there is already an implementation of the serialized path avaible in propel. i am currently developing the nested sets approach, you can contact me if you want.
Re: Nested Set [message #4612 is a reply to message #4594 ] Tue, 04 April 2006 09:47 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
Hi

I have written a class for performing nested sets which is similiar to the way that sfPager works. This was before i realised how great propel was!! I have never come across the serialized path implementation before so I am unaware how to configure this in the database and how it work etc, but i have successful generated the stub classes in propel with the isTree attribute for the table, which was great.

I am happy to forward you a copy of my nested set class if this would help and share any ideas, how may i contact you?

Thanks

Joe
Re: Nested Set [message #5091 is a reply to message #1850 ] Tue, 18 April 2006 04:15 Go to previous messageGo to next message
yoyo  is currently offline yoyo
Messages: 78
Registered: January 2006
Location: Poland
Member

If there is no problem I encourage you to put it here, Im also interested in this matter Smile
Re: Nested Set [message #7128 is a reply to message #4612 ] Tue, 06 June 2006 11:13 Go to previous messageGo to next message
archi  is currently offline archi
Messages: 26
Registered: December 2005
Junior Member
hi could u kindly send to me nested set class?
thx in advance
Re: Nested Set [message #10261 is a reply to message #4594 ] Wed, 16 August 2006 22:05 Go to previous messageGo to next message
isak  is currently offline isak
Messages: 1
Registered: August 2006
Location: Stockholm
Junior Member
Can you please give a link to this implementation? I unsuccessfully tried to find it... It would be very kind of you.
Re: Nested Set [message #10264 is a reply to message #1850 ] Wed, 16 August 2006 22:42 Go to previous messageGo to next message
joesimms  is currently offline joesimms
Messages: 38
Registered: December 2005
Member
Hi

Here is my implementation.

I have been working on this off list with Gregory Becker

The code seems to be fairly stable although not totally finished and tested, and lacks docs.

Gregory wrote a test module, and I have included some test data and a schema for you to play with, hope this helps.

FYI, I am working with the Propel Team at the moment to integrate this in Propel, so all you have to do is type

<table ... tree="nestedset">

and it will auto generate a TreePeer, and the convenience methods to the stub. I am very busy at the moment, but will post here when this has been done.

Also, you can see Gregorys previous version here, this is now decremented, but could be useful, but we have merged our code to provide this solution, which after some minor refactoring will integrate into Propel.
http://www.symfony-project.com/trac/wiki/HowToHandleHierarch icalDataWithPropel

Hope this helps

Thanks

Joe

PS Please note that when integrated into Propel, method names may change slightly, as may queries etc, so please view as a work in progress.

Re: Nested Set [message #11570 is a reply to message #1850 ] Wed, 06 September 2006 14:17 Go to previous messageGo to next message
donharold  is currently offline donharold
Messages: 99
Registered: May 2006
Member
@joesimms

This looks very promising - any details on the propel integration? I follow the propel dev list, and from what I gather, the next point release is still a bit away, not to mention it will then have to be integrated into symfony.

Not that it matters much, as it's easy to use your existing solution.

While you're at it, I have a feature request that I think is quite important:

Right now, you can't store several independent trees in a single table, because the left and right greater that/less than checks might mix up tree nodes after adding and deleting a few nodes. So I think adding a namespace field to the table would be a good idea.

In practice you'd then for example call retrieveRoot($ns) instead of retrieveRoot(), and automagically work with the selected tree from there.

// edit:

After further looking through the code in the zip, I have another question: Wouldn't methods like MenuPeer::insertAsLastChildOf($dest, $node, $con = null) make more sense as instance methods of the $dest node?

Please don't take this as criticism, I'm just curious.

Thanks

[Updated on: Wed, 06 September 2006 14:28]

Re: Nested Set [message #11573 is a reply to message #10264 ] Wed, 06 September 2006 14:39 Go to previous messageGo to next message
nautilebleu  is currently offline nautilebleu
Messages: 281
Registered: June 2006
Location: Caen, France
Faithful Member

@joesimms

Seems to be very interesting and the integration in Propel is clearly an advantage.

One suggestion if I could, I think that building the tree with a list (<ul><li>..) should be better, because it will produce a cleaner and more accessible HTML.


all about me
t-shirts
Re: Nested Set [message #18086 is a reply to message #11573 ] Mon, 18 December 2006 13:51 Go to previous messageGo to next message
heltem  is currently offline heltem
Messages: 3
Registered: December 2006
Junior Member
OK, I am very interested in nestedset support in propel layer.
So I read joesimms proposal and I made 1.2-release patch to add specific builder in order to support NestedSet generation in the same way.

Builders I made provide Stub and Base classes matching the propposed samples.

I posted a message on propel ML yesterday but I got no answer because phpdb.org seems down

Is someone here interested to provide me feedback and which way (diff, svn branch) can I share my patch ?
Re: Nested Set [message #20261 is a reply to message #1850 ] Tue, 23 January 2007 17:04 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

I'm also very interested in nested set support in symfony.

I've been playing with joesimms' classes for nested set, but i'm missing support for more than one root element - I don't know if is this possible.

I've found ruby on rails plugin for nested set support (http://opensource.symetrie.com/api/better_nested_set/, http://opensource.symetrie.com/trac/better_nested_set/)
which has this feature...

Thanks




Re: Nested Set [message #20630 is a reply to message #20261 ] Wed, 31 January 2007 08:59 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
mishal wrote on Tue, 23 January 2007 16:04

[...] but i'm missing support for more than one root element - I don't know if is this possible. [...]


AFAIK there should be only one root element.
If you need to have more top level elements you could use root as their holder - not as the 'data element'

Re: Nested Set [message #20634 is a reply to message #1850 ] Wed, 31 January 2007 10:31 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

I have used PEAR's nested set in the past and it supports more then one root element. I need to store culture in my nested_set table, and different culture needs different tree. Maybe it's bad database design Sad
Re: Nested Set [message #20637 is a reply to message #20634 ] Wed, 31 January 2007 10:51 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
hmm,
personnaly I would have one root and then cultures on the first level (just after root), but I haven't used PEAR's nested set before.
perhaps it's time to have a look at it..

[Updated on: Wed, 31 January 2007 10:51]

Re: Nested Set [message #20641 is a reply to message #20637 ] Wed, 31 January 2007 11:12 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

I don't like PEAR's nested set class. It's quite old and the code is ugly.

I think nested set is really needed Smile
I tried also Propel Tree implementation, but i think it's not usable.

I'll have to switch back to parent_id and recursion ...


Re: Nested Set [message #20643 is a reply to message #20641 ] Wed, 31 January 2007 11:21 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
I have started work on the propel adjacency model module.
It's still in a very early stage.. I'll post the code when it's ready for testing (I estimate it will be in a couple of weeks - too busy right now with other stuff)
Re: Nested Set [message #20645 is a reply to message #1850 ] Wed, 31 January 2007 11:27 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

Thanx, nice to hear this:)

Count on me with testing.
Re: Nested Set [message #20648 is a reply to message #20645 ] Wed, 31 January 2007 11:31 Go to previous messageGo to next message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
You might be interested in this: http://phpdoctrine.net/doctrine/manual/documentation.php?ind ex=6.3#6.3
Re: Nested Set [message #20651 is a reply to message #20648 ] Wed, 31 January 2007 11:39 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

Greeat! Multiple roots Smile

Quote:


The nested implementation can be configured to allow your table to have multiple root nodes, and therefore multiple trees within the same table.



Thanx chtito. I'm going to test Doctrine soon!

Re: Nested Set [message #20652 is a reply to message #20641 ] Wed, 31 January 2007 11:53 Go to previous messageGo to next message
heltem  is currently offline heltem
Messages: 3
Registered: December 2006
Junior Member
mishal wrote on Wed, 31 January 2007 11:12


I think nested set is really needed Smile
I tried also Propel Tree implementation, but i think it's not usable.

Which Propel Tree implementation did you try ? I am currently working on it to reimplement Nested Set support in Propel and any feedback is welcome.

What is missing according to you ?

[Updated on: Wed, 31 January 2007 11:54]

Re: Nested Set [message #20655 is a reply to message #20652 ] Wed, 31 January 2007 12:50 Go to previous messageGo to next message
mishal  is currently offline mishal
Messages: 31
Registered: January 2006
Member

I've tried these:

* using only Propel (isTree table attribute)
* Class found on wiki http://www.symfony-project.com/trac/wiki/HowToHandleHierarch icalDataWithPropel
* and that one posted by joesimms (found in this thread) http://www.symfony-project.com/forum/index.php/fa/115/

I'm missing support for more than one root element.

Edit: just found something I haven't tested http://propel.phpdb.org/trac/wiki/NestedSet
Re: Nested Set [message #20657 is a reply to message #20655 ] Wed, 31 January 2007 13:27 Go to previous messageGo to next message
heltem  is currently offline heltem
Messages: 3
Registered: December 2006
Junior Member
I think the still-under-developpment NestedSet implementation does not support yet usable multi-root element but I am currently working on it and feedback will be appreciated.
Re: Nested Set [message #21144 is a reply to message #1850 ] Wed, 07 February 2007 09:58 Go to previous messageGo to next message
nautilebleu  is currently offline nautilebleu
Messages: 281
Registered: June 2006
Location: Caen, France
Faithful Member

I'm also interest by a multi-root nested set implementation.

I'll look the joesimms implementation, but if you want, I'm glad to help you to develop it. Feel free to contact me ! Razz


all about me
t-shirts
Re: Nested Set [message #21306 is a reply to message #20657 ] Fri, 09 February 2007 08:51 Go to previous messageGo to next message
pezetgee
Messages: 734
Registered: March 2006
Faithful Member
Just stumbled across this: http://rpbouman.blogspot.com/2005/08/hierarchiesagain.html

Looks promising...
Re: Nested Set [message #21320 is a reply to message #1850 ] Fri, 09 February 2007 13:34 Go to previous messageGo to next message
nautilebleu  is currently offline nautilebleu
Messages: 281
Registered: June 2006
Location: Caen, France
Faithful Member

This morning, on the Symfony Google user group, a post talk about Nested Set support in Propel.
It seems that complete support will require Propel 1.3.

So I'm wondering how to update propel in symfony (just replace propel folder in PEAR/Symfony/vendor ?) and if it might break something (other than things broken by the replacement of Creole by PDO) ?

[Updated on: Fri, 09 February 2007 13:42]


all about me
t-shirts
Re: Nested Set [message #22282 is a reply to message #21320 ] Thu, 22 February 2007 12:57 Go to previous message
francois  is currently offline francois
Messages: 1627
Registered: October 2005
Faithful Member
There is a symfony plugin implementing nested sets for sf1.0.

http://www.symfony-project.com/trac/wiki/sfPropelActAsNested SetBehaviorPlugin
Previous Topic:db schema validation
Next Topic:[Solved] Dependent drop-down
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software