May 10, 2013
Drupal

Rules checklist

Author photo
Cheppers
Cheppers Zrt.

Rules is one of the most sophisticated modules you can find in the drupal sphere. It can be used to build complex and flexible systems that respond to a specific event. The three most important components of the module are events, conditions and actions. A reaction rule always needs a specified event to happen on the site, but the action takes place only if the criteria match.

Rules checklist

This blog post was written to provide a checklist before someone starts to write a custom module. In many cases a well built rule will give the same result.

Rules default settings

Events

Comment

  • A comment is viewed
  • After deleting a comment
  • After saving a new comment
  • After updating an existing comment
  • Before saving a comment

Node

  • After deleting content
  • After saving new content
  • After updating existing content
  • Before saving content
  • Content is viewed

System

  • Cron maintenance tasks are performed
  • Drupal is initializing
  • System log entry is created

Taxonomy

  • After deleting a term
  • After deleting a vocabulary
  • After saving a new term
  • After saving a new vocabulary
  • After updating an existing term
  • After updating an existing vocabulary
  • Before saving a taxonomy term
  • Before saving a vocabulary

User

  • After a user account has been deleted
  • After saving a new user account
  • After updating an existing user account
  • Before saving a user account
  • User account page is viewed
  • User has logged in
  • User has logged out

Conditions

Data

  • Data comparison
  • Data value is empty
  • List contains item
  • Text comparison

Entities

  • Entity has field
  • Entity is new
  • Entity is of bundle
  • Entity is of type
  • User has field access

Node

  • Content is of type
  • Content is promoted to frontpage
  • Content is published
  • Content is sticky

Path

  • Path has URL alias
  • URL alias exists

User

  • User has role(s)
  • User is blocked

Actions

Data

  • Add a variable
  • Add an item to a list
  • Calculate a value
  • Convert data type
  • Remove an item from a list
  • Set a data value

Entities

  • Create a new entity
  • Delete entity
  • Fetch entity by id
  • Fetch entity by property
  • Save entity

Node

  • Make content sticky
  • Make content unsticky
  • Promote content to front page
  • Publish content
  • Remove content from front page
  • Unpublish content

Path

  • Create or delete a content's URL alias
  • Create or delete a taxonomy term's URL alias
  • Create or delete any URL alias

Rules scheduler

  • Delete scheduled tasks
  • Schedule component evaluation

System

  • Page redirect
  • Send mail
  • Send mail to all users of a role
  • Set breadcrumb
  • Show a message on the site

User

  • Add user role
  • Block a user
  • Remove user role
  • Unblock a user

Rules bonus pack

Events

Rules Bonus: Views

  • After a view has been built
  • After a view has been rendered
  • Before a view is being built

Conditions

Rules Bonus: Miscellaneous

  • Check number of results from a view
  • String contains number
  • User has permission(s)

Actions

Batched Rules

  • Alter batch context

Rules Bonus: Block

  • Disable a block
  • Place a block

Rules Bonus: Miscellaneous

  • Clone a node
  • Create a date from a number
  • Get integer from string
  • Load a comment list with Views
  • Load a node list with Views
  • Load a path alias
  • Load a user list with Views
  • Load the first node in a Views list
  • Merge two strings
  • Set page title

Rules Bonus: Theme

  • Set body classes
  • Set head title

Rules Bonus: Views

  • Unset a view handler

Flags

Events

  • A node has been flagged, under "Bookmarks"
  • A node has been unflagged, under "Bookmarks"

Conditions

  • Comment has flagging count
  • Comment is flagged
  • File has flagging count
  • File is flagged
  • Node has flagging count
  • Node is flagged
  • Taxonomy_term has flagging count
  • Taxonomy_term is flagged
  • Taxonomy_vocabulary has flagging count
  • Taxonomy_vocabulary is flagged
  • User has flagging count
  • User is flagged

Actions

  • Fetch content flagged by user
  • Fetch users who have flagged a comment
  • Fetch users who have flagged a file
  • Fetch users who have flagged a node
  • Fetch users who have flagged a taxonomy_term
  • Fetch users who have flagged a taxonomy_vocabulary
  • Fetch users who have flagged a user
  • Flag a comment
  • Flag a file
  • Flag a node
  • Flag a taxonomy_term
  • Flag a taxonomy_vocabulary
  • Flag a user
  • Trim a flag
  • Unflag a comment
  • Unflag a file
  • Unflag a node
  • Unflag a taxonomy_term
  • Unflag a taxonomy_vocabulary
  • Unflag a user

Profile2

Events

  • After deleting a profile
  • After saving a new profile
  • After updating an existing profile
  • Before saving a profile
  • Profile is viewed

Related posts

Development of a sponsored contrib module - Gather Content
Author
2017-01-16
Drupal

In 2016, our team worked on a sponsored contrib module, GatherContent. The goal of the project was to recreate the module for Drupal 7 using best practices, and to create a brand new module for Drupal 8.

Drupalaton
Author
2014-07-13
Drupal

It's so good to see that the Hungarian Drupal developer companies feel and understand the nature of this community and try to give back to it to the extent of their means.