I feel I'm very close... the following one could be the solution:

http://groups.google.com/group/cake-php/browse_thread/thread/94ec5a3d33f2a935/ba469c8c052674b8?lnk=gst&q=findAllThreaded&rnum=1#ba469c8c052674b8

Only one thing:
Where must I write the "hacked" findAllThreaded function?

On 20 Ago, 23:29, albe <[email protected]> wrote:
> Thank you very much majna!
> ->find('threaded') seems to be perfect for my need... unfortunately it
> doesn't work for me (error "Undefined offset").
> And my algorithm was wrong... so I've got to get another headache...
>
> On 20 Ago, 21:01, majna <[email protected]> wrote:
>
> > "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
-~----------~----~----~----~------~----~------~--~---

Reply via email to