Module Mondays: Views Bulk Operations
on
January 21, 2008
Module Mondays: Views Bulk Operations
A couple of engineers at CivicActions were interested in the Views Bulk Operations module. Me too! So I checked it out.
Easily installed, the most important bit I can tell you about is this:
test1_node_operations() was easily created after I reviewed Drupal's API:
http://api.drupal.org/api/function/hook_node_operations/5
Working similarly to hook_menu(), it informs Drupal of the operation test1_bulk.
views_bulk_operations finds test1_bulk and it is immediately available to any bulk view. An administrator will need to check the box for 'test1 node operations' in the Operations tab of the bulk view to make this new operation available to users.
In this case, test1_bulk doesn't actually affect any node, but it gives you starting point.
Overall, Views Bulk Operations has a ton of potential. With a little more clarity/development with Actions created through the Actions user interface, this module will be of great value to developers and administrators.
- clone the view that comes with views_bulk_operations (admin_content)
- in the clone be sure to go to the Filters and select all content types for the Content Type filter (so you can see all nodes with the view)
- click Save, then start messing with it!
function test1_node_operations() {
$operations = array('test1' => array(
'label' => t('test1 node operations'),
'callback' => 'test1_bulk',
));
return $operations;
}
function test1_bulk() {
drupal_set_message('test1_bulk ran');
return;
}
Harry Slaughter January 22, 2008
There are some quirks to using actions. The one you are seeing is the fact that the Action module's email actions are *not* "batchable" for some odd reason. Actions must be batchable before they will show up on the views bulk operations configuration page.
I needed a customizable email action for VBO, so I simply copied the action from actions.inc, made it batchable and had it use the Token API for text replacement rather than simple string replacement. That action now gets a lot of use and works fine.
The key to getting the most out of VBO is creating custom actions. The default actions available are not very exciting. But when you start writing your own actions, VBO becomes very, very valuable.
And you don't actually need the actions module. VBO also supports hook_node_operations(), which aren't as flexible as actions, but work well for simple, non-configurable node operations.
Thanks for the review.
Gregory Heller January 21, 2008
Thanks Robin for this concise overview! And for posting the first in our new series "Module Mondays".












