Does this module have the feature to clone nodes child's of the node by node reference? Maybe an option I can decide to make a "soft" copy with only the references ids cloned and a "hard" copy that clones all referred nodes as well and gives me a new set of node?

Hope you can understand what I mean ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

No, I don't understand.

Please provide a proof-of-concept patch at least.

pwolanin’s picture

Status: Active » Postponed (maintainer needs more info)
Kars-T’s picture

I mean cascading cloning.

A has a node reference to B.
If I use node clone to make a clone of A the new C will point to B as well.
A->B to C-->B
C is a clone of A
B remains

What I want is that if I clone A there will be a C that points to a new D which is a clone of B.
A->B to C->D
C is a clone of A
D is a clone of B

We are currently writing such a thing for a customer and maybe I can show a patch later on. There are some problems with the possibility of endless loops so maybe all node IDs should be cached and not cloned more than once. Or you could set a depth by a GUI. For this particular case it will work but for a patch we need something more common.

Right now I just wanted to check if this feature is already available. So it is just a feature request :)

pavel.karoukin’s picture

I bet you already solved this issue, but in case you still interested in solution - here is module committed by me today - http://drupal.org/project/node_clone_reference
Basically, you can select which fields you want to clone and which - not to clone.

BIGREDPAUL’s picture

Hi was just wondering how you are going to code_clone_reference.
I need a way to link cloned nodes back to thier originals.
I ask because the link above is restricted.

FiNeX’s picture

Hi! The module linked on comment#4 is not accessibile... has it been renamed?

SocialNicheGuru’s picture

Is the project available?

SocialNicheGuru’s picture

I did a search on google and saw this. Has anyone tried it?

http://www.webindustries.co.nz/clone-node-reference-module

stevef’s picture

Hi, in regards to #8 - we had this module developed for us. As the developer was not available to maintain the module it has not been committed. If anyone wants to review, contribute and maintain - please let me know.

I can confirm that it is used extensively on a production site, and has been thoroughly tested. The module creates a set of Admin GUI options allowing you to specify Node Reference fields that need to be re-created in the newly created cloned Node.

It also optionally allows you to convert Nodes from Content Type 'A' to Content Type 'B' during the cloning process, and, convert the relevant Node Reference fields to remain consistent with the Node conversion process. So:

1. we have Content Type 'Goal Template' nodes to which we have referenced multiple 'Action Templates' nodes
2. on cloning, we clone the Node Reference field contained in the 'Goal Template'
3. we convert the 'Goal Template' to a 'Goal' and the 'Action Templates' to 'Actions' (this conversion is so we can set Permissions differently for the various CTs)
4. we are required to use a different Node Reference field in the newly created nodes of different CT, and so we also convert the 'field_goaltemplate_actionsref' to 'field_goal_actionsref'

Not sure if that last bit makes things clearer - but am happy to answer any questions. This module allows you to set the options required for steps 2-4 to occur.

Cheers,

Steve

Steve Flowers
www.webindustries.co.nz || www.hiredguns.co.nz

kevin.mcnamee@mailbox.org’s picture

subscribing

kevin.mcnamee@mailbox.org’s picture

Version: 6.x-1.x-dev » 6.x-1.0
FileSize
3.28 KB

Hi,

I have patched the Node Clone module to get this working. The solution is very clean and hopefully Drupalish. By enabling Node Clone to invoke events, the Rules module can be used to handle the logic and allow the user to do whatever changes need to be done to the cloned node.

The Event is called "Content has been cloned" and provides both the original node, the cloned node and acting user as input to a Rule. The rule can then be configured to use a Views Bulk Operation (VBO) to clone child nodes and update any node references the developer has. For example, the following code can be used to with the "Execute arbitrary PHP script" VBO action to update node references:

$cloned_parent_nid = $context['rules']['cloned_node']->nid;
$cloned_child_nid = clone_node_save($object->nid);  // This will also trigger a "content cloned" event
$cloned_child = node_load($cloned_child_nid);
$cloned_child->field_mynoderef_node[0]['nid'] = $cloned_parent_nid;
node_save($cloned_child);

By leveraging Rules, the "Content has been cloned" event can be used to trigger messages, watchdog, etc.

A diff is attached which also includes a new clone.rules.inc file. As a bonus, the diff also creates an Action called "Clone node" which could be useful for other things. There is no dependency created on the Rules module. If Rules exists then the Event will be made available to it.

Cloning nodes automatically will produce nodes with "Clone of " in the title. I found the Automatic Nodetitles useful for generating more meaningful titles.

pwolanin’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review

Interesting idea. I think the patch may be missing a trigger in the pre-populate case? Or is it not possible to handle that?

kevin.mcnamee@mailbox.org’s picture

Version: 6.x-1.0 » 6.x-1.x-dev

The prepopulate case is handled by the clone_nodeapi hook. By passing along the "clone_from_original_nid" variable, the cloned Event can be invoked on "insert".

The prepopulate case is the one that I am using on my site and it works perfectly.

/Kevin

SocialNicheGuru’s picture

I have a workplan which has several projects and each project has several tasks. Node reference is used to link them together

I would like to just copy the workplan and then have each project copied and then each task copied and all the nod references updated. Is there a way to do this using the patch above?

PS. Since node clone 6.x-1.3 there is no need to add this code as it is part of clone.module file now

 /**
+ *  Implementation of hook_form_alter.
+ *  By adding the 'clone_from_original_nid' field as a form element,
+ *  it will be available in the node object when calling clone_nodeapi.
+ */
+function clone_form_alter(&$form, &$form_state, $form_id) {
+  if ($form['#node']->clone_from_original_nid) {
+    $form['clone_from_original_nid'] = array(
+      '#type' => 'hidden', 
+      '#default_value' => $form['#node']->clone_from_original_nid,
+    );
+  }
+}
kevin.mcnamee@mailbox.org’s picture

Yes, it is possible to do cascade clones of depth 1, 2 or more. The patch is generic, triggering a "Content clone" event that Rules can act on. You will have to set up at least one generic VBO and Rule, or perhaps one VBO + Rule for each node type: workplan, project and task depending on your needs.

/Kevin

stomerfull’s picture

Hello every body

I really need this module for my site

I have installed the module in this site http://www.webindustries.co.nz/clone-node-reference-module

But i' m not able to get it working

Can you describe how to setting up the module in the admin interface of clone module?

Thank you very much for your help

stomerfull’s picture

FileSize
45.9 KB

I have a nodereference setting like in the image join in my content type
and when i duplicate node, these nodereference is not duplicate (clone)
and i'm using Clone module 6.x-1.3

thank you

stomerfull’s picture

any idea?

stomerfull’s picture

Ok,

I made ​​some changes in

function clone_noderef_nodeapi (& $ node, $ op, $ a3 = NULL, $ a4 = NULL)

of clone_noderef.module and it works like charm

:-)

Now i'm able to duplicate nodereference inside node

But basically it doesnt work because i don't use a nodereferer field

Thank you

SocialNicheGuru’s picture

Is there anyway to achieve this in Drupal 7?

stomerfull’s picture

In D7, i havent yet testing it but i think it is the same principe

kevin.mcnamee@mailbox.org’s picture

Hi,

I have rerolled the patch in #11.

/Kevin

TechNikh’s picture

+1 for D7

pwolanin’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

I did add a feature like this to D7. Not adding new features to D6 now.