Skip to main content
Commonmark migration
Source Link

EDIT: You can now find a better explanation with the code [here][3]here.

I know this is old but maybe someone comes here looking for an answer like me, this is tested on Drupal 8.

I found this [issue][1]issue and after looking at last [patch][2]patch, I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got a duplicate node with duplicated paragraphs fields. If you look at the patch you will see how to add a button to Drupal etc.

Just a note field_paragraphs is the name of my field in the content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at the time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch [3]: https://kunicmarko20.github.io/2017/05/04/Clone-Duplicate-Node-with-Paragraphs-field-in-Drupal-8.html

EDIT: You can now find a better explanation with the code [here][3].

I know this is old but maybe someone comes here looking for an answer like me, this is tested on Drupal 8.

I found this [issue][1] and after looking at last [patch][2], I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got a duplicate node with duplicated paragraphs fields. If you look at the patch you will see how to add a button to Drupal etc.

Just a note field_paragraphs is the name of my field in the content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at the time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch [3]: https://kunicmarko20.github.io/2017/05/04/Clone-Duplicate-Node-with-Paragraphs-field-in-Drupal-8.html

EDIT: You can now find a better explanation with the code here.

I know this is old but maybe someone comes here looking for an answer like me, this is tested on Drupal 8.

I found this issue and after looking at last patch, I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got a duplicate node with duplicated paragraphs fields. If you look at the patch you will see how to add a button to Drupal etc.

Just a note field_paragraphs is the name of my field in the content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at the time of writing this there is still no ported modules for cloning nodes in Drupal 8.

add link to blog post that better explained this and some grammar fix
Source Link

EDIT: You can now find a better explanation with the code [here][3].

I know this is old but maybe someone comes here looking for an answer like me, this is tested on Drupal 8.

I found this [issue][1] and after looking at last [patch][2], I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got a duplicate node with duplicated paragraphs fields. If you look at the patch you will see how to add a button to Drupal etc.

Just a note field_paragraphs is the name of my field in the content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at the time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch [3]: https://kunicmarko20.github.io/2017/05/04/Clone-Duplicate-Node-with-Paragraphs-field-in-Drupal-8.html

I know this is old but maybe someone comes here looking for answer like me, this is tested on Drupal 8.

I found this [issue][1] and after looking at last [patch][2], I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got duplicate node with duplicated paragraphs fields. If you look at patch you will see how to add button to Drupal etc.

Just a note field_paragraphs is name of my field in content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch

EDIT: You can now find a better explanation with the code [here][3].

I know this is old but maybe someone comes here looking for an answer like me, this is tested on Drupal 8.

I found this [issue][1] and after looking at last [patch][2], I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got a duplicate node with duplicated paragraphs fields. If you look at the patch you will see how to add a button to Drupal etc.

Just a note field_paragraphs is the name of my field in the content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at the time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch [3]: https://kunicmarko20.github.io/2017/05/04/Clone-Duplicate-Node-with-Paragraphs-field-in-Drupal-8.html

Source Link

I know this is old but maybe someone comes here looking for answer like me, this is tested on Drupal 8.

I found this [issue][1] and after looking at last [patch][2], I implemented :

$nodeDuplicate = $node->createDuplicate();

foreach($nodeDuplicate->field_paragraphs as $field){
    $field->entity = $field->entity->createDuplicate();
}

$nodeDuplicate->save();

And I got duplicate node with duplicated paragraphs fields. If you look at patch you will see how to add button to Drupal etc.

Just a note field_paragraphs is name of my field in content type, change it with your own.

I didn't have any problem doing it this way, maybe someone has a better way but I did not find it, also at time of writing this there is still no ported modules for cloning nodes in Drupal 8. [1]: https://www.drupal.org/node/2829316 [2]: https://www.drupal.org/files/issues/implement_duplicate-2829316-53.patch