Now I've got another little problem. From findAllThreaded I obtain a
structure like this:
Array
(
[0] => Array
(
[Post] => Array
(
[id] => 55
[parent_id] => 53
[title] => ...
[body] => ...
[user_id] =>...
[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] =>...
[forum_id] => 1
)
[Infodisc] => Array
(
[id] => 1
[title] => ...
)
[User] => Array
(
[id] => 2
[username] => ...
)
[children] => Array
(
)
)
)
)
)
Now that I have obtained the complete nested level starting from a
post, I obviously want to make operations on each of these post... but
when I try to do foreach($posts_to_move as $p) { ... } I discover that
the cycle takes into consideration only the first level!!!
Please, help me to get out of this endless nightmare...
On 21 Ago, 00:43, albe <[email protected]> wrote:
> Ok, I give myself an answer: the function findAllThreaded has to be
> modified right in the cake/libs/model/model.php file.
> Once done you can finally obtain all the nested items of one element
> of your choice!
>
> On 21 Ago, 00:30, albe <[email protected]> wrote:
>
> > I feel I'm very close... the following one could be the solution:
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/94ec5a3d...
>
> > 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
-~----------~----~----~----~------~----~------~--~---