Use recursion like this http://bakery.cakephp.org/articles/view/threaded-lists
On Aug 21, 10:41 am, albe <[email protected]> wrote: > Hi everybody, > > Thanks to the function findAllThreaded() I've obtained a structure > like this: > > Array > ( > [0] => Array > ( > [Post] => Array > ( > [id] => 55 > [parent_id] => 53 > [title] => ... > [body] => ... > [user_id] => 1 > [forum_id] => 1 > ) > > [Forum] => Array > ( > [id] => 1 > [title] => ... > ) > > [User] => Array > ( > [id] => 1 > [username] => ... > ) > > [children] => Array > ( > [0] => Array > ( > [Post] => Array > ( > [id] => 58 > [parent_id] => 55 > [title] => > [body] => ... > [user_id] => 2 > [forum_id] => 1 > ) > > [Forum] => Array > ( > [id] => 1 > [title] => ... > ) > > [User] => Array > ( > [id] => 2 > [username] => ... > ) > > [children] => Array > ( > ) > > ) > > ) > ) > ) > > If I try to do a foreach cycle over this structure in this way: > > foreach ($posts as $p) { ... } > > I discover that the cycle considers only the first post (it doesn't > consider the child). Which cycle am I supposed to do to consider every > item (child, children of the child... and so on)? > 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 -~----------~----~----~----~------~----~------~--~---
