Hi, id like to display confirmation in a javascript popup as opposed to redirect to new page to confirm the action. It would be a great feature for this module!

Comments

Nicolas Bouteille’s picture

Issue summary: View changes

I managed to do so using Colorbox Node module. You only need to add the colorbox-node class in hook_preprocess_rules_link and also some data-inner-width data-inner-height if need be...

<?php
    function your_module_preprocess_rules_link(&$vars) {
      if ($vars['rules_link']->name == 'your_rules_link_machine_name') {
        $vars['classes_array'][] = 'colorbox-node'; //here is where you can add additional classes
        $vars['attr'] = drupal_attributes(array(
          'title' => $vars['title'],
          'class' => $vars['classes_array'],
          'rel' => 'nofollow',
          'data-inner-width' => '400',
          'data-inner-height' => '160',
        ));
      }
    }
?>

NB : if you're using 2.0, don't use drupal_attributes()
#2534618: Fatal error when switching from 1.1 to 2.0 when using drupal_attributes in custom code

unfortunately, I just noticed it only worked for rules links attached to Comments. For rules links attached to nodes, after I confirm the deletion inside the colorbox, instead of being redirected to the same page, I arrive at the regular Deletion Confirmation page :(
EDIT : this actually works fine. My redirect problem was because I was using rules_link_render() function without mentioning the destination parameter.
Careful though, the destination parameter is actually the "query" parameter which needs to be an array with 'destination' inside like that:

<?php
$my_rules_link = rules_link_render('machine_name', $entity_id, array('destination' => 'your_destination_path'));
?>

The second option you have is to handle the confirmation yourself by displaying the rules link inside a tooltip that opens on click of a custom link, using Tooltipser. In that case the rules link needs to be normal again...

Nicolas Bouteille’s picture

for the tooltip I recommend the great tooltipster plugin

lionguard’s picture

You can also check out this sandbox module - it allows the triggering of modal boxes to confirm rules action executions:
https://www.drupal.org/sandbox/cmcintosh/2644004

jweirather’s picture

Thanks for the contribution lionguard! I'll have to check that out.