The Rules module can be used to automate simple and complex tasks on your Drupal site without programming. Learn how to use standard Rules features to modify content, notify users, or redirect URLs. Then we will look at how Rules integrates with other Drupal modules like Flag and Views to provide even more power. We will see how Rules provides amazing flexibility to customize your site.
1. Drupal Rules!
Scott Povlot (@spovlot)
Drupalcamp Atlanta 2012
October 27, 2012
DrupalCamp Atlanta #DcATL #drupal-rules
2. Why Rules?
Add Custom Functionality in Drupal
Create Complex Reactions to Events
Integration with lots of Modules
Fast Development
No Programming Necessary
DrupalCamp Atlanta #DcATL #drupal-rules
3. Rules Integration
Drupal Core
Entity API
Flags
Views Bulk Operations
Commerce and Ubercart
Organic Groups (OG)
UserPoints
VotingAPI
DrupalCamp Atlanta #DcATL #drupal-rules
4. Anatomy of a Rule
Reaction Rule
Event
Condition (optional)
Action
Loop
DrupalCamp Atlanta #DcATL #drupal-rules
5. Events
When to Perform the Rule
Core Events
User has logged in
After saving new content
A comment is viewed
Contributed Module Events
A node has been flagged, under "Like" (Flag)
Customer completes checkout (Ubercart)
DrupalCamp Atlanta #DcATL #drupal-rules
6. Actions
What to do when the Rule is executed
Core Actions
Send mail
Add a user role
Calculate a value
Create an entity
Page redirect
Contributed Module Actions
Unflag a node (Flag)
Update order status (Ubercart)
DrupalCamp Atlanta #DcATL #drupal-rules
7. Conditions
If the Conditions are True, Perform the Actions
And's & Or's
Core Conditions
Content is of type
Entity has a field
Data Comparison
User has role(s)
Contributed Module Conditions
Entity is a group (OG)
Check if order can be shipped (Ubercart)
DrupalCamp Atlanta #DcATL #drupal-rules
8. Redirect after Login Example
Demonstration
DrupalCamp Atlanta #DcATL #drupal-rules
9. Variables
Default “site” information
Current User
Provided by events
or actions
Node
User
Entity
Types
Text, Integer, Decimal, Truth Value, Date, Entity
10. Lists and Loops
Lists
Multiple value fields
Fetch entity by property
Fetch users who have flagged a ...
Load from a VBO View
Loops
Iterate over a lists of data
Perform actions on each item
DrupalCamp Atlanta #DcATL #drupal-rules
11. “Hints” via Conditions
Add one of the following conditions
Content is of type
Entity is of type
Entity has field
When Rules does not show type specific fields
DrupalCamp Atlanta #DcATL #drupal-rules
13. Rules Components
Reusable Chunks of Rules
Condition set (OR)
Condition set (AND)
Action set
Rule
Condition and Actions without an event
Rule set
DrupalCamp Atlanta #DcATL #drupal-rules
14. VBO Action with Rules
Demonstration
DrupalCamp Atlanta #DcATL #drupal-rules
15. Debugging Rules
Rules Settings
admin/config/workflow/rules/settings
Show debug information - Always
DrupalCamp Atlanta #DcATL #drupal-rules
17. Questions?
Drupal Rules!
Scott Povlot (@spovlot)
Drupalcamp Atlanta 2012
October 27, 2012
#DcATL #drupal-rules
DrupalCamp Atlanta #DcATL #drupal-rules