Reader small image

You're reading from  Drupal Rules How-to

Product typeBook
Published inNov 2012
Reading LevelIntermediate
PublisherPackt
ISBN-139781849519984
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Robert Varkonyi
Robert Varkonyi
author image
Robert Varkonyi

Robert Varkonyi is a senior Drupal developer and author, originally from Hungary. He has worked with clients across the globe, such as NBC Universal and Ericsson. Robert is currently working with Tincan, a leading Drupal agency within the arts, cultural, and NfP sectors. He is also the author of Drupal Rules How-to.
Read more about Robert Varkonyi

Right arrow

Loading a list of objects into Rules using VBO (Should know)


This recipe explains how to load the result of a VBO view into Rules.

We will create a view that lists all nodes that are:

  • Created by user 1 (admin)

  • Promoted to the front page

  • More than two weeks old

We will then demote these nodes from the front page using Rules.

Getting ready

Install and enable Views, Views UI, and Views Bulk Operations.

How to do it...

  1. Go to Structure | Views and create a new view that lists all the nodes that are created by user 1, are promoted to front page, and are more than two weeks old, and add a VBO field to it. Call this new view Old admin content.

  2. Go to Configuration | Workflow | Rules | Components and add a new Action set component. No parameters are needed; we will get the objects from the view.

  3. Add a new Action, Views Bulk Operations | Load a list of entity objects from a VBO View and select the view we created in the first step, as shown in the following screenshot:

  4. Optionally, enter a descriptive label for the variables and save the Action.

  5. Add a new loop in the Actions section and select the VBO view result as the list data, shown as follows:

  6. Optionally, enter a descriptive label for the variable to be used in the loop.

  7. Add a new Action within the loop Node | Remove content from front page, as shown in the following screenshot:

  8. Select the current node to be removed from the front page.

How it works...

VBO views can be used to create a list of objects for Rules to execute an action on. This is a useful feature for developers and site builders who make extensive use of views on their sites. The advantage of using this feature is that we can create complex views with relationships and contextual filters (Rules provides an interface to pass arguments to views) and perform actions on the results.

In this example, we will create a new view that lists nodes that are created by user 1 (admin), are promoted to the front page, and are posted two weeks ago or earlier. Then, by adding a VBO field to the view, we make the results of the view available for Rules to use. Because the data type provided to Rules is a list, we can create a loop in our action and perform operations on each individual item.

Previous PageNext Page
You have been reading a chapter from
Drupal Rules How-to
Published in: Nov 2012Publisher: PacktISBN-13: 9781849519984
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Robert Varkonyi

Robert Varkonyi is a senior Drupal developer and author, originally from Hungary. He has worked with clients across the globe, such as NBC Universal and Ericsson. Robert is currently working with Tincan, a leading Drupal agency within the arts, cultural, and NfP sectors. He is also the author of Drupal Rules How-to.
Read more about Robert Varkonyi