"what is the way to put an element ?"
$post_dinasty[] = $p;
try with $posts = $this->Post->find('threaded', array
('conditions'=>array('Post.id'=>$post_chose)));
http://book.cakephp.org/view/812/find-threaded
On Aug 20, 7:13 pm, albe <[email protected]> wrote:
> Hi,
> I am working on a forum which discussions are tree-structured (a post
> may have direct replies).
> Suppose that I want to collect a post and all of its replies and the
> replies of its replies and so on...
> I would like to put each post in an array in this way:
>
> $posts = $this->Post->findAll();
> $posts_dinasty=array();
> foreach($posts as $p){
> if($p['Post']['id']==$post_chose){ //$post_chose is the post
> of which I want to collect the dinasty
> $post_dinasty = $p; //(?)what is the way to put an element
> in the array?
> } else { //altrimenti
> foreach($post_dinasty ad $pd){
> if($p['Post']['parent_id']==$pd['Post']['id']){ //if I
> find the father of this post in the posts already collected
> $post_dinasty = $p; //(?) I want to put it in the
> array.... in which way?
> }
> }
> }
> }
>
> I think that the algorithm is correct, can you confirm it?
> What is the way to put the elements in the array?
> Thank you very much 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
-~----------~----~----~----~------~----~------~--~---