Warning message

Newsletter category Drupal Developer newsletter format has not been set to HTML. There will be no statistics recorded for this newsletter.

Drupal: Pass ids as arguments to page VBO action

This CodeLet add already implemented "Pass ids as arguments to page" on VBO.
Place this CodeLet to your custom module, you can see the customization on Bulk Operations field on the image.

CodeLet: 

/**
* Implementation of hook_action_info
* @return multitype:multitype:string boolean The
*/

function mymodule_action_info() {
return array(
'mymodule_passid_to_other_page' => array( // declare the function name to be used. Replace the name with your function name
'type' => 'entity', // can be node,comment etc
'label' => t('Pass ids as arguments to page (Custom)'), // the name of the operation which is displayed to the user.
'aggregate' => TRUE,
'configurable' => FALSE,
'hooks' => array(),
'triggers' => array('any'),
),
);
}

/**
* Implementation of a Drupal action.
* Passes selected ids as arguments to a view.
*/
function mymodule_passid_to_other_page($entities, $context = array()) {
$base_url = $context['settings']['url'];
$arguments = implode(',', array_keys($entities));
// Add a trailing slash if missing.
if (substr($base_url, -1, 1) != '/') {
$base_url .= '/';
}
drupal_goto($base_url . $arguments);
}

/**
* mymodule_passid_to_other_page_views_bulk_operations_form
* @param unknown $options
* @return multitype:string The Ambigous
*/
function mymodule_passid_to_other_page_views_bulk_operations_form($options) {
$form['url'] = array(
'' => t('URL'),
'' => 'textfield',
'' => t('Enter a URL that the user will be sent to. A comma-separated list of selected ids will be appended.'),
'' => isset($options['url']) ? $options['url'] : '',
'' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
);
return $form;
}

Views Bulk Operations add another Pass ids as arguments to page

By saru1683 on Tue, 12/05/2015 - 11:44am

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback