Coding for Rules

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

This series covers the basics and some more of how to write your own plugins to extend the Rules module. It includes:

  • A conceptual overview of the Rules modules
  • Writing action plugins
  • Managing rules data as parameters for Rules plugins
  • Writing conditions
  • Writing and invoking Rules events
Tutorials in this course
More information

This series covers the basics and some more of how to write your own plugins to extend the Rules module. It includes:

  • A conceptual overview of the Rules modules
  • Writing action plugins
  • Managing rules data as parameters for Rules plugins
  • Writing conditions
  • Writing and invoking Rules events

This intro chapter contains a quick presentation of the Rules module from a conceptual perspective. It includes:

  • Actions, conditions, events
  • Data types: the importance of entities, relationships and tokens
  • Lists and loops
  • Components and parameters
  • Some words about the Rules user interface

If you would like to see more about configuring Rules before continuing this series on writing code to integrate with the Rules module, you can watch the Learning the Rules Framework series. Note that Johan is using the Module filter module to provide the tabs and filter box on his module administration page.

More information

This chapter shows how to create a basic Rules action. It covers:

  • The role of the module.rules.inc file
  • Using hook_rules_action_info
  • Writing action callbacks
More information

This screencast shows how to add parameters to your actions, for example to allow site builders to select which user object an action should work with.

More information

This screencast shows how to:

  • Use text as an input parameter for an action
  • Provide your action configuration with a customized select list
  • Restrict input for a parameter to "direct input" (and not data selection)
More information

This screencast shows:

  • How to declare that an action provides new data objects to Rules
  • How to actually send the created data to Rules
  • How to save parameters that are manipulated by the action (but not created by it)

The example used creates an action that returns the number of hits in a selected view.

More information

This screencast shows how to create a condition plugin for Rules:

  • How to declare new conditions for Rules
  • How to provide the condition callbacks with parameters to act on
  • The big similarities and the few differences between actions and conditions

In the example, a condition is built to check which view type a provided view has.

More information

This screencast shows how to:

  • Declare a Rules event
  • Declare the data provided by the event
  • Use that data in a rule

The example used creates an event "View is being rendered", passing along information about which view is being used.

Categories
Drupal 7
More information

This screencast shows how to:

  • Invoke a Rules event
  • Send parameter data to a Rules event

This is shown by an event triggered every time a view is being rendered, sending the name of the view as a parameter.

More information

This screencast gives miscellaneous tips when writing Rules plugins, such as:

  • Some words on declaring new data types for Rules
  • How to restrict access to plugins
  • How to form alter plugin configuration forms
  • How to provide additional form validation
  • How to use the "base" property to provide a non-default callback function
  • How to invoke events programmatically with all arguments in a single array
  • How to use drupal_static() to share variables/values with other parts of Drupal
This course appears in the following guides:
Module Development
A guide to module development in Drupal 7.

Legacy Module Development