Hi, I've been playing around with the tree functionality as well.
Looking at the code, you'll notice that the reorder method calls
itself recursively.  If you want to reorder the entire tree, simply
pass no arguments... e.g.

$this->reorder();

  Overall, I'm pretty impressed so far with how easy the tree methods
make it to deal with the adjacency list hierarchy model.  I've had to
code this kind of stuff from the ground up in SQL Server, and it was a
major PITA.

On Oct 29, 5:27 am, MonkeyGirl <[email protected]> wrote:
> Hi.
>
> I'm trying to order atreesuch that for any given node on thetree,
> all its children appear alphabetically, including the top level.
>
> If I understand thereorder() method correctly (it has sparse
> documentation athttp://book.cakephp.org/view/229/Advanced-Usage#reorder-518
> but the API 
> athttp://api.cakephp.org/class/tree-behavior#method-TreeBehaviorreorder
> is more informative), then you need to pass it the IDs that need
> editing.  I want toreorderthe whole entiretreethough, so I made my
> own reorderAll() method in /app/app_model.php:
>
>   function reorderAll($options = array()) {
>     $parentIDs = $this->find('list', array(
>       'fields' => array(
>         'parent_id'
>       )
>     ));
>
>     $parentIDs = array_unique($parentIDs);
>
>     foreach ($parentIDs as $parentID) {
>       if (!empty($parentID)) {
>         $options['id'] = $parentID;
>         $this->reorder($options);
>       }
>     }
>   }
>
> Is this a good way of approaching it?  The most obvious problem I can
> see at the moment is that the top level still isn't getting
> alphabetised, and I'm not sure how to do this.  I'm also still not
> sure ifreorder() recurses as far as it can, or just one level.
>
> Thanks for any help or suggestions!
>
> Zoe.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to