I have been looking at nestedSet behaviour in symfony using doctrine, to display a nestedSet hierachy in an admin module for my CMS.
I have come across: http://redotheoffice.com/?tag=doctrine-drag-drop-admin-generator-symfony-nestedset which at first glance looked great and I have now implemented this.
My problem comes with trying to order root nodes, since they are organised by root_id, which this implementation does not do.
I have found the following: http://blog.rajatpandit.com/2010/03/27/ordering-list-of-items-doctrine-symfony-1-4/ but I have already created a custom template to render the drag/drop nestedSet, so I'm trying to use this.
//generator.yml
object_actions:
new:
_edit: ~
_delete: ~
moveUp:
moveDown:
I've copied over the code into my actions.class.php and my model classes form the link above.
When trying to move a node up or down it throws an error on: $this->current_report->getId(), in executeUp() and executeDown()
Fatal error: Call to a member function getId() on a non-object
If I then try to create the current_report object using $this->current_report = new Tree(), i then get another error:
Fatal error: Call to a member function setPosition() on a non-object this is in my Tree.class.php file and the method is swapWith()
Position is the field I'm using to sort by rather than root_id.
If someone could help me with this, I'd muchly appreciate it.
Thanks