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

Using loops and lists (Must know)


This recipe explains the basics of lists and loops, creating a list of objects, and executing an action on each item.

How to do it...

  1. Create a new rule configuration and set the Event to Node | After saving new content.

  2. Add a Condition, Node | Content is of type and set it to Article.

  3. Add a new loop and set Data selector to node:field-tags.

  4. Add a new Action System | Show a message on the site and set a message.

How it works...

Using lists and loops in Rules is the way to handle multiple value fields and execute Actions on each individual item. While this particular recipe is not too useful in the real world, it can be used as a basis for more advanced features, for example, when using a node reference field to provide reference to a list of related nodes. We can then load that list of referenced nodes and create a loop that will send a customized e-mail notification to the authors of the referenced nodes.

There's more...

We can also add items to a list by adding an Action, Data | Add an item to a list. An example use case could be to automatically add a taxonomy term to the newly created node or add a user to a user reference list.

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