How to Use The Views Bulk Operations Module in Drupal 8

How to Use The Views Bulk Operations Module in Drupal 8

The default Content overview in Drupal is a view. You can perform actions on multiple nodes by selecting one of them from the dropdown and applying it in bulk.

How to Use The Views Bulk Operations Module in Drupal 8

The Views Bulk Operations module for Drupal 8 enhances this list of actions by adding some more actions to it. For example, you can change the author or delete the comments of one or multiple nodes with just one click.

How to Use The Views Bulk Operations Module in Drupal 8

Keep reading to learn how to use this module!

Note: This example will not work if you generate content with the Devel module.

Step #1. – Install the Required Modules

  • Open the terminal application of your PC and place the cursor in the root of your Drupal installation
  • Type: composer require drupal/views_bulk_operations

How to Use The Views Bulk Operations Module in Drupal 8

  • Click Extend
  • Scroll down and enable Views Bulk Operations and Actions Permissions
  • Click Install

How to Use The Views Bulk Operations Module in Drupal 8

The Actions Permissions submodule allows you as admin to allow or restrict access to the default (or custom) Views Bulk Operations actions to certain users, based on their role within the Drupal platform.


Step #2. – Create an Authenticated User

  • Click People > Add user

How to Use The Views Bulk Operations Module in Drupal 8

  • Enter the required data
  • Click Create new account

How to Use The Views Bulk Operations Module in Drupal 8


Step #3. – Create a View

Besides the 2 default content types in Drupal, I have created an extra content type called “Sponsored Article”. Furthermore, I have created 10 nodes between Articles and Pages as admin user.

  • Click Structure > Views > Add view
  • Give the view a proper name
  • Check Create a page
  • Change the number of items to display to 50
  • Click Save and edit

200609 drupal vbo 005

Let’s tweak the view a little bit.

  • Click Content under the FORMAT section and change the format to Table
  • Click Apply two times
  • Click the Add button under the FIELD section and add the Body field
  • Set the formatter to Trimmed with a limit of 150 characters
  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

  • Add the field Authored by (Content)
  • Click Add and configure fields
  • Uncheck Link label to the referenced entity
  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

  • Enable the Views bulk operations field
  • Click Add and configure fields

How to Use The Views Bulk Operations Module in Drupal 8

  • Scroll down under the Selected actions and select Change the author of content

Take a look at the other actions available. You might be wondering if there is a difference between Delete selected entities and Delete content item. For example, if you have a multilingual site, the entity would be the base article and the content items would be the translated articles. If you are editing an Italian translation, Delete selected entities would erase the whole entity from the database, whereas Delete content item would only eliminate the Italian article. This principle applies also in Drupal Commerce with Products and Product displays.

  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

  • Rearrange the fields like in the image below
  • Click Apply

How To Use The Views Bulk Operations Module in Drupal 8

  • Edit the Table settings
  • Click the checkbox to make the Authored by field sortable
  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

  • Save the view

Step #4. – Bulk of Editing Nodes

You can head over to the view page now.

  • Click Authored by to sort by the author field (i only have one author in my installation)

The upper checkbox with gray background allows you to select all results on the page (not in the whole view), in case there were more than 50 results.

  • Select 4 – 5 nodes
  • Select Change the author of content from the dropdown

How to Use The Views Bulk Operations Module in Drupal 8

You will only have this option since we selected only this action when configuring the field on step #3.

  • Click Apply to selected items
  • Scroll down and select the name of the authenticated user from Step #2.
  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

Those entities belong now to that particular user.

Let’s edit the view one more time. A blue-grey pencil will appear if you hover on the top right area of the view. Click that pencil to edit the view.

  • Add a filter
  • Search for and select the field Authored by
  • Click Add and configure filter criteria

How to Use The Views Bulk Operations Module in Drupal 8

  • Check Expose this filter to visitors, to allow them to change it
  • Click Apply

How to Use The Views Bulk Operations Module in Drupal 8

  • Save the view

Now you have a text box to filter out by the author of the content.

How to Use The Views Bulk Operations Module in Drupal 8

In this tutorial, you learned how to sort content by column in a Views table, and how to filter it by a field with an exposed filter. You learned also the basic usage of the Views Bulk Operations module for Drupal 8.

It is possible to code custom actions to meet the specific needs of the content and/or the site. This is out of the scope of this tutorial, but you can check the documentation of the Views Bulk Operations Example submodule, which comes with the main module by default.

Thanks for reading!

Author

  • Jorge Montoya

    Jorge lived in Ecuador and Germany. Now he is back to his homeland Colombia. He spends his time translating from English and German to Spanish. He enjoys playing with Drupal and other Open Source Content Management Systems and technologies.

0 0 votes
Article Rating
Subscribe
Notify of
1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Szántó Péter
Szántó Péter
2 years ago

Thank you Jorge. It was a great help.

1
0
Would love your thoughts, please comment.x
()
x