1. Introduction

Last modified: February 15, 2009 - 11:48

The Rules module is a rule-based event-driven action evaluation system.

This means, that one is able to configure various actions that will then be fired on certain events.

Events

Rules allows you to configure actions to be fired on various events. For example, if a user is creating a new content, the event "Content has been created" occurs. So Rules allows you to react to this event by firing actions. There are a lot of different events available, and contributed modules can even introduce new events. Some more examples of events would be
• a user has logged in
• content has been viewed
• after saving a new comment
..

Rules events have nothing to do with calendars. ;)

Actions

Rules provides various actions, which let you actually do something. Some examples of actions are
• send a mail to a user
• unpublish content
• delete a comment
..

So the combination of Events and Actions could read like any of these examples:
- When "a user has logged in", "send a mail to a user".
- When "content has been viewed", "unpublish content".

Some actions can be configured (eg. what email address to use when sending mails), and some need no configuration (unpublish content). Some simple and configurable actions are provided by the Rules module, and contributed modules may provide further actions.

So let's have a look at how actions & events play together:

This is an example, that shows how Rules is firing actions. It shows an action, which is configured to be fired on the event "Content has been updated".

Note that there are two different kind of actions: First off there are "drupal core actions", compatible with the trigger module and also with the Rules module. Then there are Rules-compatible actions, that can be only used with the Rules module, and these are a bit more powerful.

Conditions

Conditionals allow you to configure actions so that they are only executed if the configured conditions are met.

Again, let's have a look at how conditions interact with actions and events:

Here the action is only fired if the condition "Content is a Story" is evaluated to TRUE.

Like actions, Rules provides some configurable conditions and contributed modules may provide further conditions. Rules also supports negating conditions as well as the concept of condition groups, which are logical operations like OR and AND.

 
 

Drupal is a registered trademark of Dries Buytaert.