Using VBO and Actions to manage your content – Part1: VBO

Did you ever find a Drupal feature that was so incredibly simple and easy to use that you were sure that everyone else already knew about it? Using Views Bulk Operations (VBO) together with Actions was one of the moments for me. Asking around to my fellow developers, I discovered that the use of the combination of VBO and Actions is common. In this blog series, I am going to walk you through using VBO and Actions to create some kick-ass administration forms.

Neil Hastings
#Drupal | Posted

Did you ever find a Drupal feature that was so incredibly simple and easy to use that you were sure that everyone else already knew about it? Using Views Bulk Operations (VBO) together with Actions was one of the moments for me. Asking around to my fellow developers, I discovered that the use of the combination of VBO and Actions is common. In this blog series, I am going to walk you through using VBO and Actions to create some kick-ass administration forms. First we will look at the basic concepts around VBO and Actions, then I will show you 2 examples: comment administration and user administration. Both will be made available as a feature.

Part 1: Views Bulk Operations

Views Bulk Operations is a contributed module by kratib. There is a good general description of VBO on the project page:

This module augments Views by allowing bulk operations to be executed on the nodes displayed by a view. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied on the selected nodes.

So what does this mean? It means that anything you can display in a view (and I mean anything) can be managed, in bulk, with VBO using Drupal actions. To turn a view into a VBO view just select the "Bulk Operations" style.

 

This exposes a large number of settings to help you configure VBO for your use.  You should recognize the top portion of the settings from the table style.   Below the "Default Sort Order" there are the settings for VBO.

To execute operations:   VBO integrates with BatchAPI and Job Queue.   If you expect the running of the operation to take longer then the allowed PHP time limit, you can use BatchAPI to process the actions. Selecting Job Queue will place the actions in a queue to be run at the next cron.   Otherwise you can use "Invoke them directly" to run the actions on a normal form submission.

Display operations as:  These are display options for how the view and operations form will appear.  Most of these are self-explanatory.  Here is a summary of the settings:

  • Display of Buttons:  You have two choices for the selections of how the action select will be displayed:  "Dropdown selectbox with Submit button" or "Each action as a separate button."   A separate button for each action is only useful if you are using a few actions. Otherwise the interface becomes cluttered.
  • Hide select all checkbox:  There really isn’t a reason why you would not want this selected.  Using exposed filters will help you limit the content the in view and using the select all checkbox become very useful.
  • Skip confirmation step:  This skips the good old "Are you sure?" step.  This is really up to you and your client.
  • Display processing result:   This displays a status message that lists how many items were affected and how long it took to complete all of the actions.   Keep in mind that the message will be displayed along with any message from the action itself.  Below is an example of deleting 3 nodes (you can see the results in the red box).   I recommend turning this off on a production site.

  • Merge single action's form with node selection view: This places all options for the configurable actions on a single page.

Selected operations:  This displays a list of all actions that are exposed to Drupal using hook_action_info() in all enabled modules.  You can select as many as you would like to display.  The actions change based upon the type of view (node, comments, users, etc).

Exposed Filters

One of the coolest parts of VBO is that it operates on a view so you can use all of the views functionality to extend the usability.  One of the most useful views features to use with VBO is exposed filters.  The correct use of exposed filters can greatly improve the end users experience with administering content by allowing the user to narrow down the list of items that they want to perform the operation on.  When designing the view, be sure to ask your client what criteria are important and what actions are to be done to the content.

Conclusion

This post is the first in a four part series about content administration in Drupal using actions and views bulk operations.  This first post was an overview of VBO.  The next post will be a walkthrough of actions, and will be more technical with code examples.

Next blog post in this series.

Neil Hastings