Duct Tape for Drupal

Ryan Price
Blink Reaction

9 years in Drupal, 15 in web


Orlando, FL

April 11-12, 2015


Faves: Theatre, Pottery, Photography, Podcasts, Beer, Coworking, Mentoring, and Open Source







iTunes, Stitcher, Miro or
your favorite podcast app.

art & technology

community & work



[lash-ing] verb

1. to secure items together in a somewhat rigid manner


  • non-permanent
  • utilitarian
  • improvised
  • re-usable materials
  • methodical

What about Duct Tape?

What about Duct Tape?

"Lashing for Drupal"
did not have the same ring to it. :P

Duct Tape

  • non-permanent
  • utilitarian
  • improvised
  • re-usable materials
  • methodical

Duct Tape!


Custom Code


Drupal is not about writing code

Drupal is all about features

(not those features)

"using the internet to eliminate middlemen"

Dries Buytaert

the programmer is a middleman between your data and your business

not knowing how to code can be as bad as having as having a middle man

How to: Rules

1. Deconstruct
2. Modify
3. Construct
4. Compose
5. Trigger

Title Text

when this happens

if this is true

perform this action




before I leave for work

if there are dark clouds in the sky

bring the umbrella from the hall




after I leave for work

if the day is not Friday

get credit card from wallet

purchase coffee with credit card

if the time is before 8:45am

when this happens

if both of these are true

set up this data

perform this action with data


Woah, not sure what this rule does...

I can edit this "Test" message though.


If I unpublish a node,
delete all the comments

What Event?

Saving a node

What Condition?

If it's unpublished

What Action?

Delete the comments

Until we learn to use "Loop", we have to delete comments one-by-one


When this happens...

I have an event

Add a Condition for Unpublished

What about

I want the opposite of published

Event and Condition

I Need an Action to Perform

There is no Action

referring to Comments

Comments are

Entities, though

What is all of this?


What is all of this?

I can drill down into a Node and one comment at a time

Event, Condition and Action

...but only deletes the first comment

I'll add a Loop

Drill down to comment list

Change "Current List Item" to

something more meaningful to this rule

Delete Entity needs to be nested under Loop

Don't forget to Save!

Still one more edit needed

Drill down to comment list

Change "Current List Item" to

something more meaningful to this rule

The Finished Rule

Loop over and Delete the right way








Send email to these users


Run another Rule on these Nodes

Rule Inception

Notice, there is no "Event" in a component

Rules Components



Triggering Components

Views Bulk Operations

Triggering Components

Drupal Commerce

Triggering Components



Drupal 8?

Site building based on Drupal 8 core integration wins

  • Admin UI usability improvements

  • Simple Views Bulk operations in core

Reusable components

  • Plug-in based architecture & fully object-oriented code

  • Rules data selector for tokens, contexts and other use cases

  • Typed data widgets & formatters

  • Embeddable Rules UI components to integrate actions & conditions

Evolved developer experience

  • Unified DX based on Drupal 8 plug-in system

  • Symfony 2 event system integration

  • Deployable config via CMI


  1. Drupal 8 core integration & Rules core engine          $$$

  2. Rules core API completion

  3. Rules 8.x release

Rules Recipes

at, the Drupal Pastebin

Useful Rules Modules

Rules Scheduler

Create Components

The "Event" is Cron

ex. Reminder: You haven't edited your profile in a year

Views Bulk Operations

Create Components

Edit View "Bulk Operations" Field and add your Component

Make sure you have a "Node" Parameter
(or whatever Entity your view pulls)


Show me the emails

Log all messages

Reroute instead of sending


Enabling Payment Types

Adding Taxes

Price Adjustments

Rules Forms Support

Event: When a form is being validated

Invalidate a form before it gets saved

Validate fields, display custom messages

Don't need to use Form API

Used by Resource Conflict

Resource Conflict

Check if an event is in the same room at the same time

Use Taxonomy Terms for "rooms"

Can invalidate the form, so it won't be saved if a conflict exists

Workflow Rules

React to changes in Workflow State

e.g. Draft, In Progress, Needs Review, etc.

Cache Actions

    Clear Drupal cache bins
    Clear CSS/JS cache
    Clear the cache of specific views
    Clear the cache of specific panel pages
    Clear the cache of specific mini panels





Excellent Rules support built in

Rules drive email Notifications

Logintoboggan Rules

Event when the user account is validated.

Organic Groups

Events when a user is added to a group,

Joins/Leaves a group

When group content is added

Rules Repeated Events

My preferred means of creating recurring events.

Good example of Provided vs Parameter

Context Rules

Event when a Context is activated,

from the Context module

Lashing for Drupal

Ryan Price
Blink Reaction

Rules: Duct Tape for Drupal

By Ryan Price

Rules: Duct Tape for Drupal

The Rules module - the duct tape of Drupal - use it to build new features and business logic. Rules can be immensely useful for Intranet websites, or sites with complicated sets of permissions and publishing workflows. It is also used by default in Drupal Commerce sites to manage taxes, discounts and payment types. Not sure if you need Rules? Are you ... a Site Builder, but not a coder? a Drupal Commerce User? starting or ending a sale on a certain Date? an Organic Groups Admin? sending E-Mail notifications from your site? creating repeating Events? creating Views Bulk Operations actions? flagging Nodes as spam, based on user feedback? This session will provide you with: a formula you can apply to decide when to use rules a system for asking the right questions before you create a rule how to find examples of similar rules you can modify modules that provide extra actions and conditions rules that can be helpful in specialized sites, like commerce sites, event-driven sites or community sites

  • 1,110
Loading comments...

More from Ryan Price