When writing my own actions I set the redirect within my custom form submit like so: $_GET['destination'] = 'my/target';

Would be good to have that option for the default actions as well. Or is there already a way how to override the default redirect from views_bulk_operations_form_submit()?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

leymannx’s picture

Issue summary: View changes
ikeigenwijs’s picture

I would like this feature added in Bulk operations under the form of a optional custom field.

ikeigenwijs’s picture

Status: Active » Needs review
FileSize
2.17 KB

Solved this.
Added it in the UI with an extra option field.
No changes for current projects, default behaviour is the same.
But no more form_alter for custom redirects! Much more user and not programmer friendly.

I got help from David_Hernandez on irc.
patch attached

David Hernández’s picture

Glad to be able to help!

Wim Leers’s picture

Status: Needs review » Needs work
  1. +++ b/views/views_bulk_operations_handler_field_operations.inc
    @@ -57,6 +57,7 @@ class views_bulk_operations_handler_field_operations extends views_handler_field
    +        'custom_redirect_at_end' => array('default' => ''),
    
    @@ -135,6 +136,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field
    +    $form['vbo_settings']['custom_redirect_at_end'] = array(
    

    Is the "at end" part even necessary? Up to the maintainer to decide, but it feels strange.

  2. +++ b/views/views_bulk_operations_handler_field_operations.inc
    @@ -135,6 +136,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field
    +      '#title' => t('Page to redirect after completion of batch'),
    

    Page to redirect *to*

  3. +++ b/views/views_bulk_operations_handler_field_operations.inc
    @@ -135,6 +136,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field
    +      '#description' => t("Default redirect to VBO page when left empty"),
    

    1) Use single quotes, like all other translatable strings here.

    2) The English is very difficult to parse.

ikeigenwijs’s picture

FileSize
2.13 KB
1.2 KB

Fixed the issues.
And used an other string to explain the default behaviour

ikeigenwijs’s picture

Status: Needs work » Needs review
ikeigenwijs’s picture

Still applies cleanly on current dev.
This runs for the last 9 months on our production environment without problems.

ikeigenwijs’s picture

bump

wmfinnegan’s picture

Any chance this feature could handle tokens from the view? I've got an EVA with VBO and I want to come back to the page with the EVA.

bunset’s picture

Patch #6 worked perfectly for me!
This should be included in the module, it is awesome!.
Please include this feature in new version of vbo module! :)

Thank you very much!

ikeigenwijs’s picture

I'm trying to get commit access.

ibuildit’s picture

I wonder, how can we make this field accept tokens, for example [path]...

g089h515r806’s picture

Status: Needs review » Reviewed & tested by the community

Patch #6 worked perfectly.

ikeigenwijs’s picture

Still applies cleanly on current dev

A screenshot of the UI addition.
No change or impact for current install and views.

ikeigenwijs’s picture

I would like to see this added to -dev

ibuildit’s picture

Patch #6 works great, but it does NOT work when "Skip batching" is selected. Needs updating there please.

ikeigenwijs’s picture

Still applies cleanly to dev

2307381_6.patch
Checking patch views/views_bulk_operations_handler_field_operations.inc...
Hunk #1 succeeded at 63 (offset 6 lines).
Hunk #2 succeeded at 142 (offset 6 lines).
Checking patch views_bulk_operations.module...
Hunk #1 succeeded at 744 (offset 12 lines).

@ibuildit #17
I took a look when skip batch is used
views_bulk_operations_direct_process( ...) is called

I would try at line 835

  if ($execute_directly) {
    // Execute the operation directly and stop here.
    views_bulk_operations_direct_process($operation, $rows, $options);
    // @todo: add redirect here
    //+  if ($vbo->options['vbo_settings']['custom_redirect']){
    //?something like this?  drupal_goto($vbo->options['vbo_settings']['custom_redirect'])
    //+  }
*/
    return;
  }
Chris Matthews’s picture

ikeigenwijs’s picture

Patch in #6 still applies without difficulty to latest 7.x-3.x-dev (16-08-2020).

leymannx’s picture

Priority: Normal » Major

Let's finally raise priority to push this forward. Will we need to port this to D8?

kopeboy’s picture

How to redirect from a specific bulk operation?
If you have multiple options on the same view (for example Rules' components that you created), and just one needs a redirect at the end, how can we set the redirect for that one only?

tcweb’s picture

Is there a way to use replacement patterns in the redirect URL? We would like to have it redirect back to the node edit page. Thanks