[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bricolage-general
Subject:    Re: Moving a subelement from one story to another
From:       "David E. Wheeler" <david () kineticode ! com>
Date:       2009-09-08 21:32:50
Message-ID: C98D1A33-FD75-40C3-9293-39C92065E893 () kineticode ! com
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic