Book Image

Drupal Rules How-to

By : Robert Varkonyi
Book Image

Drupal Rules How-to

By: Robert Varkonyi

Overview of this book

Rules is what every Drupal site builder and developer has to use when creating event ñ action-based applications. The framework provides a highly flexible way to create sophisticated, condition-based functions any Drupal based system into an interactive application. Rules makes Drupal rule the CMS world."Drupal Rules How-to" is a practical, hands-on guide that provides you with a number of clear step-by-step exercises, which will help you take advantage of the real power of the Rules framework, and understand how to use it on a site builder and developer levelThis book demonstrates the power and flexibility of the Rules framework. It discusses the main aspects of the module both from the site builder and developer perspective, from basic and advanced Rule configurations using Events, Conditions, Actions and Components to getting familiar with the Rules API. You will also learn how to use additional modules together with Rules to further extend the possibilities of your Drupal system, such as Rules Scheduler to schedule the execution of your Rule configurations and Views Bulk Operations to execute Rule configurations on a view result list. The book also demonstrates the main API features that enable you to create your own Events, Conditions and Actions, provide new data types to Rules and execute your configurations programmatically
Table of Contents (7 chapters)

Displaying a message on the site (Must know)


This recipe describes the steps to be taken in order to display a custom message on the site after creating a new article.

Getting ready

All recipes in this book assume that the reader is familiar with the Rules UI and/or has read the first recipe in this book, Understanding the basics of Reaction Rules (Must know).

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 CONTENT TYPES to Article, as shown in the following screenshot:

  3. Add an Action and select System | Show a message on the site.

How it works...

By using the Action, After saving new content, we're asking Rules to react on content creation. This means that the rule will fire every time a new content has been created in the system. By using Conditions, we can tell Rules to only fire the action if the created content type is Article (or any other content type). In the MESSAGE field, we've used REPLACEMENT PATTERNS to insert chunks of data from the objects available in our current rule configuration.