1

I would like to use the event in Rules "After cloning a node" but unfortunality this does not work. (see Event "After cloning a node" by node clone module is not working).

I tried to patch the module but did not succeed.

I would like to solve this with rules with :

Event - "Node Edit on type foo" and then add some conditions.

Does anybody knows a good condition for this? What can I compare?

Are there other solution possible?

I need it for the folowing situation: the user has two options for a node: (1) Edit (2) Clone

(1) The edit option is just going to the edit form. Normal editing should be done.

(2) The clone option makes a copy of the Content Type and then starts editing in this node. Before the user is starting this editing two fields in the content type should be empty.

--- Patch log (#8)
$ patch -p1 <2212039-8.patch
patching file clone.pages.inc
Hunk #1 FAILED at 160 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file clone.pages.inc.rej

--- Patch log (#8) With option --ignore-whitespace
$ patch -p1 --ignore-whitespace <2212039-8.patch
patching file clone.pages.inc
Hunk #1 FAILED at 160 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file clone.pages.inc.rej
5
  • What I sometimes do in such cases is to create a temporary hack: that patch only replaces 1 line by 6 other ones, and a bit further adds another dozen or so lines. Just using eyeballing and copy-and-paste of those relevant lines (and some shift left/right edits) should allow you to achieve the equivalent of applying the patch. I hesitate to post this as a real answer, since IMO your question is about some Rules alternative, and not really about how to apply the patch anyway. Right? Commented Aug 26, 2016 at 12:21
  • I agree about the patching. I'm more interested in the rules solutions..
    – Justme
    Commented Aug 26, 2016 at 12:23
  • @pierre, you are totally correct. I just add to my rule if the word "clone" is in the path and i have the difference :-) Put your comment in a answer and I will mark it :-)
    – Justme
    Commented Aug 26, 2016 at 12:55
  • 1
    Heb nog 48 issues open :-)
    – Justme
    Commented Aug 26, 2016 at 13:08
  • 1 hour / issue, done by the end of the weekend ... Commented Aug 26, 2016 at 13:15

3 Answers 3

1

Try to think of a way to better describe what you're trying to do, and for which using that specific event does not work (because of that bug).

Obviously, it doesn't matter what the subsequent Rules Condition and/or Rules Action would be (after you have "an" alternative for that Rules Event you are asking about).

But sometimes the solution for a problem, is to avoid the problem from happening, right? E.g. maybe there is some specific path you could try to intercept (also using the Rules module), right before/after that event occurred. I seem to remember node clone also has such path. And if anything else fails, use Rules Event "Drupal is initializing", followed by a Rules Condition to check such path (if needed using RegEx also ... I bet you know about that Rules trick also).

0

You should really try first to apply the patch or patches.

  1. Save the patch file(s) into the node_clone folder
  2. cd into that folder
  3. apply patch #8

    patch -p1 < 2212039-8.patch

  4. check if the problem persists and apply patch #9 if it does

    patch -p1 < node_clone-7.x-1.x-add_preparing_clone_rule-2212039-9.patch

  5. check if the problem still persists
  6. :-(

You need to try both patches I guess and see if the error is fixed.

Cheers!

Issue reference on D.O.: https://www.drupal.org/node/2212039

4
  • thxs, I include the patch error why I cannot patch this module
    – Justme
    Commented Aug 26, 2016 at 11:43
  • Can you try it again with --ignore-whitespace as an option for patch? Commented Aug 26, 2016 at 11:47
  • Done see log in the question :-(
    – Justme
    Commented Aug 26, 2016 at 12:05
  • You got some line-ending problem there. Are you on windoze? Could you try converting clones.pages.inc using dos2unix? Commented Aug 26, 2016 at 12:14
0

I made a custom rules action module that clones any node, based on this code it returns new cloned node NID, then in rules do other stuff with new NID, code of my rules action:

  <?php
  /**
  * Implement hook_rules_action_info()
  * Declare any meta data about actions for Rules
  */

  function clone_poliza_rules_action_info() {


  $actions = array(
    'clone_poliza_action' => array(
        'label' => t('Clone a node'),
        'group' => t('cadena'),

        'parameter' => array(

          'poliza_nid' => array(
                  'type' => 'integer',
                  'label' => t('node NID to be cloned'),
                  ),

              ),


        'provides' => array(
            'new_poliza_nid' => array(
                    'type' => 'integer',
                    'label' => t('new cloned node NID'),
                    // 'wrap' => TRUE,
                    //'format' => 'full_html'
                    ),
                  ),
      ),
    );
      return $actions;

  } // fin de actions_info


  function clone_poliza_action($poliza_nid) {

  $node = node_load($poliza_nid);

  $new = clone $node;
  $new->is_new = true;
  unset($new->nid);
  unset($new->vid);
  unset($new->tnid);
  node_save($new);

  $new_poliza_nid = $new->nid;

  return array('new_poliza_nid' => $new_poliza_nid);

  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.