I'm doing a simple forum which should support nested replies. So, I
decided to use the Tree Behavior.

models/forum_entry.php
-----------------------------------------------------------------
<?php
class ForumEntry extends ForumAppModel {

        var $name = 'ForumEntry';
        var $displayField = 'subject';
        var $actsAs = array('Tree', 'Containable');
        var $belongsTo = array('User');

}
?>
-----------------------------------------------------------------

The tree in my database looks like this:

- Testing
--- ASubSubject
------ ASubSubSubject
- Another Subject

How do I retrieve a node with parent_id = 0 (like "Testing" or
"Another Subject") and all of its children while preserving the tree
structure?

Using $this->ForumEntry->children($id) flattens the tree structure to
this:

-----------------------------------------------------------------
Array
(
    [0] => Array
        (
            [ForumEntry] => Array
                (
                    [id] => 5
                    [parent_id] => 4
                    [lft] => 2
                    [rght] => 5
                    [user_id] => 1
                    [subject] => ASubSubject
                    [body] =>
                    [created] => 2008-07-01 22:58:56
                    [modified] => 2008-07-01 22:58:56
                )

        )

    [1] => Array
        (
            [ForumEntry] => Array
                (
                    [id] => 6
                    [parent_id] => 5
                    [lft] => 3
                    [rght] => 4
                    [user_id] => 1
                    [subject] => ASubSubSubject
                    [body] =>
                    [created] => 2008-07-01 23:16:52
                    [modified] => 2008-07-01 23:16:52
                )

        )

)
-----------------------------------------------------------------

Suggestions are very much appreciated :) Been wasting a whole day on
this issue now.

Thanks in advance!

--~--~---------~--~----~------------~-------~--~----~
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