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 condition groups (Should know)


This recipe describes the usage of condition groups and the ability to combine Conditions.

We'll create a rule that sends an e-mail to the administrators if either a new article or any content type gets posted on the site that has an image field (field_image).

How to do it...

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

  2. Add a new Condition, Entities | Entity is new.

  3. Add an OR Group.

  4. Add a new Condition to the group by clicking on Add condition in the group's row, as shown in the following screenshot:

  5. Add the Condition, Node | Content is of type and set the content type to Article.

  6. Add another Condition to the OR group, use Entities | Entity has field and set the field to field_image.

  7. Add an Action to the rule configuration, use System | Send email to all users of a role, select the administrators role and fill out the SUBJECT and MESSAGE fields.

How it works...

To create complex Conditions, in Rules we can use condition groups. This way we can create a chain of Conditions using AND or OR groups. AND groups require all Conditions within the group to evaluate to TRUE, while OR groups require only one Condition to evaluate to TRUE.

There's more...

The following section describes combining of conditional groups:

Combining condition groups

We can also combine condition groups, that means we can create condition groups within condition groups. Again, it is advised that Debugging is turned on when creating nested condition groups as it can save a lot of time figuring out why a configuration doesn't work as expected.

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