You are here

Have you ever wanted to replicate/clone a node in Drupal?

If you have been working on Drupal creating websites then I am sure you must had a need to clone or duplicate a node. Let me give you an example. These days I am working on a website for one of my client where we need to display electronic house hold products like Water Heaters, Ventilation Fans, Cooks Tops etc. Now most of these products in the same category have similar attributes but only difference in size or color. Now when we add a new product it is a pain to fill all the fields that contains the product specifications. I thought there must be a way to clone it. That will save lot of time and more importantly it will save me from frustration.

There is one Drupal module called Replicate. provides a main cloning function, along with several hooks to control exactly how a field is duplicated based on its type, add info after cloning, and supports custom fields and entities. It is intended to developers and does not contain any GUI (for the moment anyway).

The goal is to provide a way to easily clone any entity, and to allow developers to be able to control exactly how entities are replicated, based on their type or the fields they contain, and to be able to easily extend the replication control to custom fields or entities.

There is another module called Replicate UI that provides a tab in each node interface for cloning the node. Simply click on the tab called "Replicate" and it will create a new node with all the fields pre-filled. Cool!

There is one problem with Replicate module and Field collection. We are using field collection for various categories. Now when we replicate the node, the duplicated node refers the field collection of the original node. That means if we duplicate a product lets say Water Heater of 5 letre and modify the capacity field to 10 letre (stored in field collection) then it modifies the capacity field of the original node too. In fact both the node has the same field in the database. The duplicated node just refers to it. This problem is only there for Field collection fields.

However there is another module called Replicate Field Collection, that solves this issue. After installing this module the replicated node contain its own set of field collection values.

This is only cool module that we came across today and I thought I should share it with you guys. Enjoy.