
david at kineticode
Sep 8, 2009, 2:32 PM
Post #4 of 4
(767 views)
Permalink
|
|
Re: Moving a subelement from one story to another
[In reply to]
|
|
On Sep 8, 2009, at 2:30 PM, David E. Wheeler wrote: > This won't work. You pass an element type to add_container, not a > container. Pass it to add_element(), instead. But clone it first: > > use CLONE; > if (my $from_subel = $from_story->get_container("subel")) { > $to_story->add_element( CLONE::clone($from_subel)- > >prepare_clone ); > $to_story->save; > } > > You have to use CLONE::clone() because prepare_clone changes the > element in-place (basically just sets the ID to `undef`), and you > don't want to mess it up in $from_story. Sorry, make that: $to_story->get_element->add_element( CLONE::clone($from_subel)- >prepare_clone ); Best, David
|