On Mon, Oct 22, 2012 at 1:19 PM, bs28723
<bill.stoltz@boosterwebsolutions.com> wrote:
> Sorry, if my question was not clear.
>
> I want to "copy" the entire branch to another location. So, if I want to
> copy a branch that has 5 children,
> then I need to create the new parent node first, then once I have this ID, I
> can then create the 5 children nodes.
> That is a fairly easy example. But what about a branch that has 4 levels
> and 5 nodes?
>
> Is seems like I have to walk the original tree and create each node, then
> sub-node, then leaf, etc, etc.
> Anyone done this before? Any suggestions?
Hi Bill,
Yes I have done this before, but I didn't find an elegant solution so
I did exactly what you mention and walked the tree (to a fixed depth)
and inserted the nodes.
I'll post the code up somewhere now just in case it saves you a bit of
time, but it's pretty ugly.
I know what you mean though - it seems to be a pretty common
requirement so I'm surprised there isn't a more obvious way of doing
it. I guess using find('threaded') and unsetting the parent_ids
didn't work?
Thanks,
Alex
--
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
alex@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | Hosting
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
Wednesday, October 24, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment