May 17 2012
May 17

Sometimes Drupal opens up a big can of whoop-up process on ya, and Rules Scheduler is one of those gems.  Rule Scheduler allows you to use rule triggers to schedule rule sets.

Use Case:Ever want to send an email the day before a scheduled event?  We use CCK Sign-up and wanted to send an email to users one week before an event, as well as the day of.  We also needed to send teachers views of the roster of students

Here’s the 2 minute mojo on it http://www.youtube.com/watch?v=55HwOzFHoB8 and it just highlights the mistakes I was making.

The recipe came out of Drupal documentaiton, and these two tutorials got me 90% of the way:

working with scheduled rules

working with scheduled rules

And I thought I was home free, however I ran in to a pretty stupid problem that took me a minute to understand = all the identifiers need to have tokens in them with unique values or else they overwrite themselves in the database.

Solution? Easy = add some tokens – [node:nid] worked for me

The nicely scheduled rules

The nicely scheduled rules

Another fun feature in this project was revisiting one of my favorite modules: Rules Views Integration.  The cool thing about scheduling a rendered view in a rule set is that the rule gets rendered at the last minute and so you can schedule (in our case) a class roster to go out and it’ll have the most up to date information possible at the time of sending.

NB: I also ran in to a problem where cron wasn’t sending my emails initially.  I have no idea why it was stuck, however Ultimate Cron has been a good friend of late and unlocking and running the tab got it back on track = I haven’t seen it stall in a few weeks now.

Ultimate Cron unlock and run run run

Ultimate Cron unlock and run run run

 

Something else I haven’t gotten into yet, however, is the use of the Rules Scheduler Views.   Something tells me there is some magic to be had in there, used correctly.  At this point however I’m just using the off-the-shelf defaults.   I know of no Views Bulk Operations for scheduled rules, so perhaps the default info is all there is to know.  In any case, it’s an elegant solution to working with drupal’s cron functions.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web