Drupal 7 Views Bulk Operations module

By shane
Mon, 2012-11-19 19:35
Daily Dose of Drupal Episode #52

Share with Others

Learn how the Drupal 7 Views Bulk Operations module makes creating administrative views easy. The VBO module makes it simple to perform actions on multiple nodes from one simple interface.

In this episode you will learn:

  • How the Views Bulk Operations module can be used to perform actions on multiple pieces of content
  • How to apply bulk operations on a simple Drupal 7 view

Hello everybody and welcome to another Episode of the Daily Dose of Drupal, we’re on Episode Number 52 today. I’m Shane, you can follow me on Twitter @smthomas3, you can also got o codekarate.com and sign up for the newsletter and check out everything else on the website.

Today we’re going to be going over the Views Bulk Operations Module. I’m just going to over to the very basics of it because you can do a lot with module and it integrates in with Rules and a couple of other things that you can see here that play nicely with the Views Bulk Operations module but we’ll go ahead and get started and I’ll show you simple example and then you can take it from there.
First thing I’m going to do is hop over to my command line and I’m going to use Drush to download the module. You can see it has two modules; Actions Permissions and Views Bulk Operations. Actions Permissions I believe it creates a permission for each of the various Views Bulk Operations so you can separate it out who can use which operation.

So I have my test site here, I’m going to hop over to the module’s page and I already have Views installed so you’ll need to make sure you have views installed if you do not already. You’ll also notice the Views Bulk Operations module requires the Entity module.

So I’ll go ahead and search for Drupal Entity and you can see that the Entity API module is here so you’ll need to download that as well, so go ahead and do that and I’m just going to go Drush Enable Views Bulk Operations and Entity, go ahead and click Yes and if I refresh the page on my modules page you’ll see that Views Bulk Operations module has been turned on, it looks like I’m using 7.x-3.0 and we’re going to go ahead and create a very simple view to show you what you can do here.

So I’m going to add a new view; I’m just going to call it VBO Test and we’re going to show content of type, we’ll go ahead and show all and we’ll go ahead and leave the rest of that the same. Over here we’re going to go ahead and just click on Continue and Edit, we’ll just leave it at most of the defaults. Now the trick here is going to be changing the format I believe, we’re going to change this to a table and we are going to go ahead and keep the defaults here, go ahead and apply.

So now we have a very basic View, the next step is of course to get the Views Bulk Operations filters, I guess you can call them Setup. I guess it’s not really filter, it’s more of like a dropdown to perform Bulk Actions on the view and just a quick step back so you can understand what this does.

What this module actually does is it allows you to … let’s say you have a list of content and you want to maybe perform one action on that entire lists at once. This is going to create checkboxes along the left side of the View, allow you to select Multiple and then perform one action on multiple selections at the same time.

The other thing that you might want to take a look at. I’m just going to go over the basics today so may want to look at the documentations so there’s a Read Documentation page on drupal.org and this is going to walk you through some actions and snippets if you need to add that, looks like there’s not much there but VBO for Drupal 7 is going to come over and give some Rules Integration, some Aggregation things and just some basic information.

So you may want to also look at that for a little bit on how to get started but we’re going to go ahead and create this or finish creating this view here. So right now it just shows the title, we need to go ahead and add a new field, we’re going to click on Bulk Operations content and that’s going to add the checkbox to select the row for the Bulk Operations. I can of course add other fields, let’s say we want to show the comment counts, comment status and let’s see if we want anything else here, the post, the date and we’ll go ahead and show content sticky as well just so we can look at that, go ahead and hit Apply.

You can see the Bulk Operations; it allows you to select which Bulk Operations you want to be available. So let’s go ahead and select a couple of them so you can override the label, you can skip the confirmation step, we’re just going to add a couple and we’ll come back and look at this. So we’re also going to make Content Sticky and make Content Unsticky and we’ll go ahead and say we want to skip the confirmation step on those.

The other thing is you’ll notice they say In queue the operations instead of executing it directly and I believe what that does is it just queues up that process so it doesn’t immediately take action and if have a … if you’re doing actions on a lot of nodes at one time, that may be useful to make sure that you’re not trying to do too much and then I believe it will get run on the next Cron run and then maybe broken up depending on how many different pieces of content you’re making a change too.

We can also unpublished contents and published contents and we’ll go ahead and hit Apply to All Displays and we’ll the rest of these at their default just so we can get a look at how it’s going to work, I’m going to click Save and I’m going to click on View Page here and you’ll see … obviously it’s not an order and probably moved this checkbox way over here to the left but you can see that it shows that none of these are sticky.

So I’m going to go ahead and select two of them, you can see now I have this Operations Field set up here, choose Operation and I’ll make the contents sticky, I’ll execute it and you’ll notice that now I have two of them that are sticky, I’m also going to go ahead and … let’s say we wanted to unpublished everything, I’m going to click and say Unpublished Content, execute, you’ll notice this one asks me to confirm it so I’ll go ahead and I’ll hit Confirm and now you’ll notice that nothings shows up here because if you go into the View it’s only showing contents that’s published, so you know that that work, we’re going to remove this so we’ll show All Content, save it, come back to the page and you’ll notice that now they’re all showing again, I’m going to go ahead and republished those.

So as you can see this can really be used for administration pages for changing lots of different pieces of contents at once. So if you want to turn comments off for a lot of different pieces of content, you want to publish a bunch of content that wants unpublished and make them sticky, you know all those different operations that you saw, it’s very easy to do with Views, it’s point and click and pretty much makes it easy for you to control the actions or control the workflow on your site and control the content in a much more refined way.

So we’ll take a look at in one more time, you can see there’s a whole bunch of different Bulk Operations, now of course it can’t do everything but it is extensible and that’s where reading it up on how it can work with Rules module and how you can create your own actions, your own Bulk Operations can be used to extend the system and basically create various extensible Views, I can do any type of administration actions that you want.

So that’s it for this time, it’s really pretty simple but this module is extremely powerful and I recommend everyone to take a look at it if they haven’t already and we’ll be back again tomorrow with another exciting topic, Drupal related of course and I’ll see you again next time. Thanks for watching.