The Linux Page

Actions in Drupal, or should I say Rules?

I spent hours today to find this one module: Rules.

In most cases, you can set up a rule in Drupal with their Actions and Triggers and it will work just fine. The fact is that these options are extremely limited if you want any kind of condition on the Rule before triggering the action.

The idea is very simple:

1. Something happens

2. Check whether it is of interest1

3. Trigger the action

I needed that functionality for a couple of websites because I wanted to get an event whenever someone created a new page, but not for any type of node! I'm really only interested in two types: Forum & Submit or Testimonial. (If you have a site where people can create their own blog, then you could trigger the events on Blog too!)

The Rules module does just that. You create a new Rule, then you assign what triggers the rule. For instance: a new user, or a new node, or an updated node, or a new term, or a new menu (oops! not yet available in the current version! but very soon...).

Now that you have a rule and a basic trigger, that basic trigger generates some data (i.e. a node, a term, a user...) and you can check out that piece of data. The result is that you can impose a condition. On a node, you can check the node type, smong other things. That means you can check whether it is a Forum node or a Blog node. You can name your conditions so that way you know what they are in your own words.

You can even test whether the content will be published to the front page (or not!) and fire an action in that case. For instance, you could force a node to be published 3 hours after it was created whether or not the author wanted to (don't ask me why that would be a good idea!)

Oh! Yeah! You can actually schedule everything... you could do the opposite, unpublish everything and force the publishing of all the new nodes at midnight only. Why you'd want to do that, no clue, but you can.

 

  • 1. This part is what is missing in Drupal Core v6.x