[development] clone a node
Lluís
enboig at gmail.com
Tue Jul 22 06:51:59 UTC 2008
ok, I will do the way I wrote then. Thanks
On Mon, Jul 21, 2008 at 3:46 PM, Bryan Ollendyke <bto108 at psu.edu> wrote:
> There's a switch statement based ajax function in outline_designer
> (http://drupal.org/project/outline_designer) called duplicate. The best way
> to clone a node is to load it with drupal node_load then clear out the nid.
> Then call node_save and it'll look at the node, see that there isn't a nid
> and assign it one. The rest of the fields will be saved via the nodeapi
> hooks. The function you wrote before looks very similar to the one I used.
>
> btopro
>
> On Mon, Jul 21, 2008 at 7:44 AM, Lluís <enboig at gmail.com> wrote:
>>
>> I have developed a simple group system (similar to OG in some ways,
>> very diferent in others) so I need a user beeing able to import nodes
>> from other groups to his own.
>> To do so I have created a form which loads all the nodes from other
>> groups as checkboxes. The checked items will be cloned to his group.
>>
>> I haven't tried node_clone, but I think it is UI oriented; I just need
>> to clone a node knowing its ID (all group permissions, etc... are
>> rewritten using nodeapi of my custom node).
>>
>>
>> On Mon, Jul 21, 2008 at 11:59 AM, Nathaniel Catchpole
>> <catch56 at googlemail.com> wrote:
>> > You could take a look at the node_clone module if you haven't already:
>> > http://drupal.org/project/node_clone
>> >
>> > On Mon, Jul 21, 2008 at 10:55 AM, Lluís <enboig at gmail.com> wrote:
>> >> I have developed a custom module with custom node types and I need to
>> >> make users able to clone nodes; would this be a good way to do so?
>> >>
>> >> $clone=node_load($value);
>> >> $clone->is_new = true;
>> >> $clone->uid = $user->uid;
>> >> unset($clone->nid);
>> >> unset($clone->vid);
>> >> node_save($clone);
>> >>
>> >>
>> >> --
>> >
>>
>>
>>
>> --
>> *La vida és com una moneda, la pots gastar en el que vulguis però
>> només una vegada.
>> *La felicitat ha de ser compatible, compartible i cooperativa.
>> *Envellim quan els records superen les il·lusions.
>> *Als llocs desconeguts només s'hi arriba per camins desconeguts.
>> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>
>
--
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*La felicitat ha de ser compatible, compartible i cooperativa.
*Envellim quan els records superen les il·lusions.
*Als llocs desconeguts només s'hi arriba per camins desconeguts.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.
More information about the development
mailing list