Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be great if it was possible to clone a node as an action in the Rules module.
Comment | File | Size | Author |
---|---|---|---|
#21 | node_clone-rules-integration-450000-21.patch | 1.46 KB | skyredwang |
#16 | 450000-16-rules_action_for_cloning.patch | 1.24 KB | StoraH |
#15 | 450000-15-rules_action_for_cloning.patch | 1.25 KB | StoraH |
#14 | 450000-14-rules_action_for_cloning.patch | 1.25 KB | StoraH |
#12 | 450000-12-rules_action_for_cloning.patch | 1.25 KB | StoraH |
Comments
Comment #1
Dave ReidOff-topic note: Darn! I was so close to creating node #450000. :) I had 449998!
Comment #2
mitchell CreditAttribution: mitchell commentedtagging
Comment #3
turadg CreditAttribution: turadg commented+1 subscribe
Comment #4
sonictruth CreditAttribution: sonictruth commentedI would like to see this functionality as an action as well so that it can be exposed to Views bulk operations. I am looking into ways to clone all nodes of a particular language in order to create a new language based on a preexisting one.
Comment #5
pwolanin CreditAttribution: pwolanin commentedApparently there are some issues with i18n at the moment.
An action would only make sense for the save-then-edit mode probably - but even then seems like a little bit of a mismatch. The functional code here is quite minimal, so for a lot of these cases probably writing a little custom module is the right solution.
Comment #6
deggertsen CreditAttribution: deggertsen commentedSubscribe #695088: Copy Node Operation
Comment #7
pwolanin CreditAttribution: pwolanin commentedno patches coming, so closing.
Comment #8
star-szrClosed #1516496: Node clone could trigger an event in 'Rules' as a duplicate of this issue. Bumping to 7.x, if someone has a patch please re-open this issue.
Comment #9
mitchell CreditAttribution: mitchell commentedActually:
You don't need an external module for this.
Create a component, "Convert story to article" with a parameter, type = 'node' name/id = 'story'.
* Load the selected entity/node: (which will provide your story for acting on)
* Create a new entity: article
* Populate a field (aka. set a data value): [story:title] to [node:title]
* Populate a field: body = [story:body] to [node:body]
Call it whenever you want.
Comment #10
Itangalo CreditAttribution: Itangalo commented@mitchell: This method only works if you explicitly copy all the content of all the fields, which might be tedious (and you might not know in advance what fields will be present).
Attached is a patch for cloning nodes with Rules, making me a poster on issue 450000. :-D
Comment #11
StoraH CreditAttribution: StoraH commentedComment #12
StoraH CreditAttribution: StoraH commentedThanks Itangalo! It seems to be a problem when calling the clone_node_save function. It overrides the original nodes data so you can't access it in your rule. This patch solves it but I think it could be done in a better way.
Comment #13
mitchell CreditAttribution: mitchell commentedItangalo, you make your point well. :-)
One other thing though about the method I brought up, re: "(and you [must] know in advance what fields will be present)". This would be a use case for #1704282: Add "required" (allow null/empty) option to component parameters.
I'm still rooting you guys on!
Comment #14
StoraH CreditAttribution: StoraH commentedComment #15
StoraH CreditAttribution: StoraH commentedI manage to screwed up the patch again :( This one should work though..
Comment #16
StoraH CreditAttribution: StoraH commentedOk, didn't work... Left some of the code from my first patch in there. I think this thread is cursed. The sad thing is that I did test it but not in the right way. Try this instead.
Comment #17
arkjoseph CreditAttribution: arkjoseph commentedany chance the patch can be applied to D6?
Comment #18
StoraH CreditAttribution: StoraH commentedI will take a look at it in the weekend.
Comment #19
skyredwangIt seems this thread is a duplicate of #1720330: add Rules integration (event) for node clone, and the other thread has a more recent patch.
Comment #20
skyredwangSorry, the other patch mentioned above only added event condition in rules. This thread is about adding action to rules.
Comment #21
skyredwangAttached is based on @Itangalo original patch and against head.
Comment #22
skyredwangtips: if anyone is thinking about updating one of many fields' values for the cloned node in rules, just 1.) add a Content Type check 2.) Set a Value on the field (this actually doesn't update the original node) Before clone the node
Comment #23
skyredwang#21 patch seems to have problem with entity caching. In order to make it work,
We have to disable entity caching in Rules (entity.eval.inc)
The last parameter "TRUE" is forcely reseting entity cache
I don't know why clone_node_save() could flush entity cache of the original node.
Comment #24
skyredwangI created a seperate issue for entity caching problem #2062749: Node Clone breaks entity cache of the original node , which needs to be fixed first. But, the latest patch to this issue works.
Comment #25
Yuri CreditAttribution: Yuri commentedSince the entity caching problem was fixed, so I guess the patch in #21 can be committed.
Comment #26
apmsooner CreditAttribution: apmsooner commentedTested patch in #21 and confirm it works fine.
Comment #27
pwolanin CreditAttribution: pwolanin commentedcommitted