I'm searching a module to clone several nodes automatically when i create a project node type. To explain better : When i create a new node of Project type for exemple, i need to clone some nodes and tie this nodes to my node project.

I have tried node_clone but we should use a button to clone the node. For the moment i developped a small code to clone my node like this :

$p1->title='Processus P1'.$projectid;

But i had a second problem with the field_collection. when i cloned the nodes, the field_collection keep the same reference and when i modify a field collection, all the nodes cloned field_collection was modify...

How can i fix this problem ?

PS : Sorry for my english..



Node clone module has a hook for this, hook_clone_node_alter(&$node, $context). When you clone nodes programmatically, make sure you alter their state and values inside this function.

function module_name_clone_alter(&$node, $context){
    switch ($context['method']) {
        case 'prepopulate':
          // Change field values ....


        case 'save-edit':
          // Perform operations when saving the node.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.