Quick Node Clone
Introduction
The Quick Node Clone module adds a "Clone" tab to a node. When selected, a new node is created and fields from the previous node are populated into the new fields.
This is potentially duplicate work of Node Clone (https://www.drupal.org/project/node_clone), but as of release they don't have a stable D8 version and this code was created for a project from scratch in a reusable manner. This is focused on supporting more variety in field types than core's default cloning.
Future @TODO: Support more than just nodes! It could be expanded to all Content Entities fairly easily. This will likely be in its own properly named module with a better method for adding a UI to other content entities.
-
For a full description of the module visit: https://www.drupal.org/project/quick_node_clone
-
To submit bug reports and feature suggestions, or to track changes visit:https://www.drupal.org/project/issues/quick_node_clone
Requirements
This module requires no modules outside of Drupal core.
Recommended modules
It currently supports cloning of most field types including Inline Entity Form and Field Collection.
- Inline Entity Form - https://www.drupal.org/project/inline_entity_form
- Field collection - https://www.drupal.org/project/field_collection
Installation
Install the Quick Node Clone module as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.
Configuration
- Navigate to Home >> Administration >> Configuration >> Quick Node Clone setting. Here you can customise text to prepend to title as per your needs

- Clone publication status of original

If it's checked then the publication status will be cloned from the Original node that we clone.
If Unchecked the publication status will be cloned from the “default publish status of the content type” of that particular node.
- Exclusion list
You can exclude particular content type and it's field
- This module also supports 'paragraphs', allowing us to exclude any paragraph field from being cloned, similar to nodes

- Permissions
This module provides a set of permissions. Go to admin/people/permissions/module/quick_node_clone and for any content type, we can grant permission to clone its nodes.

How to use
- Go to available existing node and edit
- A Clone tab is now available on edit node.
- Select the Clone tab and a new node is created and the fields from the previous node are populated as per configuration.
- Make appropriate edits and Save New Clone.
Hooks provided by the module
1. hook_cloned_node_alter()
Example Usage
Let's consider a practical example where we want to modify certain properties of the cloned node:
use Drupal\node\NodeInterface;
/**
* Implements hook_cloned_node_alter().
*/
function mymodule_cloned_node_alter(NodeInterface $cloned_node, NodeInterface $original_node) {
// Change the title of the cloned node.
$cloned_node->setTitle('Modified Title');
// Check if the cloned node has a specific field and update its value.
if ($cloned_node->hasField('field_example')) {
$cloned_node->set('field_example', 'New Field Value');
}
}mymoduleshould be replaced with the machine name of your custom module.$cloned_noderepresents the cloned node object that you can modify.$original_noderefers to the original node being cloned, providing context for your alterations.
2. hook_cloned_node_paragraph_alter()
Example Usage
Let's consider an example scenario where we want to update the value of a specific paragraph field during the cloning process:
use Drupal\paragraphs\Entity\Paragraph;
/**
* Implements hook_cloned_node_paragraph_field_alter().
*/
function mymodule_cloned_node_paragraph_field_alter(Paragraph $paragraph, $field_name, $settings) {
// Check if the paragraph has a field named 'field_place' and update its value.
if ($paragraph->hasField('field_place')) {
$paragraph->set('field_place', 'New Changed Place');
}
}mymoduleshould be replaced with the machine name of your custom module.$paragraphrepresents the cloned paragraph entity that you can modify.$field_nameindicates the name of the paragraph field being processed.$settingsprovides additional information about the field.
Maintainers
- David Lohmeyer (vilepickle) - https://www.drupal.org/u/vilepickle
- Neslee Canil Pinto - https://www.drupal.org/u/neslee-canil-pinto
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion