This screencast shows how to start using Rules Scheduler. It does this by mimicking the Comment Closer module – closing the comments on articles two weeks after they are created. The screencast covers:
- Rules Scheduler needs components – you can only schedule prepared components
- Components can be scheduled as actions, for example from reaction rules
- The evaluation time for scheduled tasks is set with strtotime(), which means that you can use highly flexible expressions
- You can also use data selection, combined with offsets if you want to
- Every scheduled task should have a unique task ID, or it will replace existing tasks
- Scheduled tasks are displayed under the Schedule tab on the Rules admin pages
- You can delete tasks manually if you want to
- You can schedule tasks manually, without the need of reaction rules
- It is sometimes useful to execute rule components manually, to see that the scheduled tasks will work as expected
Additional resources
Rules guide (Drupal.org)
This screencast shows how to go about debugging Rules configuration. It covers:
- Enabling the debug information in Rules, showing rules evaluation.
- How to drill down into Rules’ debug messages.
- That most (or all) times, it is your configuration and not the Rules engine that has the bug.
- That the most common bug is condition that evaluates in an unexpected way.
- How to see how long time rules execution takes – and why/when this may be important.
- How to use the debugging action in Rules, to inspect the data in Rules.
Additional resources
Rules guide (Drupal.org)
This screencast shows how to work with export and import of Rules configuration, in particular using the Features module. It covers:
- Why you should use the Features and Strongarm modules.
- How to export Rules configuration with Features.
- How to import Feature-exported Rules configuration to a site.
- What reverting rules configuration means, and how to do it from Rules or Features.
- How to (eventually) export Rules configuration manually, and some words about the high readability in the Rules export code.
- How to import manually exported Rules configuration, including some available options/tweaks.
- Why configuration management is an important issue for Drupal.
For more information and tutorials on the Features module, check out the Drupal Deployment with Features & Drush Series.
Additional resources
Rules guide (Drupal.org)
This screencast presents a way to automatically create the article promotions used in the previous screencast. Topics covered are:
- Using the after new content has been created event, which does provide content NID
- Working with rule set components.
- Creating new entities with Rules.
- Setting field values in new entities – even complex fields like images.
- Force-saving entities, for example to get node IDs.
Additional resources
Rules guide (Drupal.org)
This screencast presents a way to help manage article promotions, separate content types used for promoting articles, providing more flexibility than standard teasers. The screencast shows how to have promotion nodes being published, unpublished and deleted in sync with the articles they belong to. Topics covered are:
- Reacting on the node deletion event.
- Using fetch entity by property to load a list of all relevant promotion nodes.
- How to have the loaded list unlimited in length.
- Using the delete entity action.
- How to call rule components from a reaction rule.
- Why it might be a good idea to have actions in separate components when acting on node updates.
- Cloning rule components.
- Publishing and unpublishing nodes.
Additional resources
Rules guide (Drupal.org)
This screencast shows how to set up Rules to allow comment writers to be notified when replies are posted to their comments. It covers:
- Adding a checkbox to the comment form, turning on or off reply notifications
- Sending e-mails to the comment author when new comments are posted
- Not sending e-mails when replying to own comments
- Some words about checking “entity has field” on the correct entity
Additional resources
Rules guide (Drupal.org)
This screencast shows how to set up Rules to allow node authors to – optionally – receive e-mail notifications when comments are posted to his or her content. It covers:
- Adding a checkbox to user accounts, turning on or off comment notification
- Sending e-mails to a node author when new comments are posted
- Not sending e-mails to the author if he/she was the one writing the comment
Additional resources
Rules guide (Drupal.org)
Login Redirects
FreeThis screencast shows how to set up Rules to mimick parts of the Login Destination module. It covers:
- How to redirect administrators to the content admin page on login
- How to redirect non-adminsitrators to the front page on login
- That you need the “force redirect” option when redirecting on login (yes, really!)
- Some words about utilizing user permissions instead of user roles for conditions
Additional resources
Rules guide (Drupal.org)
Components
FreeWhy creating Rules components? Here is why!
- You can reuse and simplify configuration
- You can export each component individually
- You can use rules components to perform conditions from within actions
- You can execute components manually for easier debugging (or just for the sake of executing their actions)
An important aspect of components is that they have variables – parameters that must be sent to the component when executing it.
Additional resources
Rules guide (Drupal.org)
Combining Conditions
FreeThis screencast explains how to use AND and OR groups in Rules to configure more complex conditions. This is demonstrated by creating a rule that notifies administrators when content is promoted to front page using an OR group. (The same procedure can be used to create an AND group.)
The screencast covers:
- How to combine conditions
- How to create an OR group
- Some advice about the order of conditions
- How to delete reaction rules
- Why you shouldn’t use the “send e-mail to all users in a role” action
- Why it might be useful to have messages printed out when configuring complex rules
Additional resources
Rules guide (Drupal.org)
This tutorial guides you on a quick safari through the actions, conditions and events provided by Rules core. It covers:
- A quick look at some actions provided by Rules
- A quick look at conditions provided by Rules
- A quick look at events provided by Rules
- Some words about data objects being provided to Rules by the triggering events
- Some words about multiple events in one rule limiting the available data (rather than expanding)
Additional resources
Rules guide (Drupal.org)
This tutorial presents data types and the data selection method for input in Rules. This is the most important difference between Rules 1 (D6) and Rules 2 (D7).
- How to use data selection to explore available data and drill down to selected properties
- Using the data comparison condition
- Using the set a data value action
- That Rules recognizes different types of data, and verifies when necessary
- That Rules knows that not all data is writable, and verifies when necessary
- How to create composite tokens, extending the tokens listed in the replacement patterns
- Making field values accessible to Rules
- Using reference fields to access new data, such as tags on an article or nodes in a node reference field
Additional resources
Rules guide (Drupal.org)
Learning the Rules Framework
CourseLists and Loops
FreeThis tutorial shows how to manage lists in Rules – data types corresponding to arrays of other data types. It covers:
- How to loop through multiple-value data in Rules, to act on each individual data entry
- That lists are their own data types in Rules
- That each primary data type automatically gets a list type as well
- How to add data to lists
- How to only add data if it is not already present
- How to select whether to add new data to the start or end of the list
- How to load new entities into Rules (by id)
- A few words about other ways of fetching entities, such as by property or with Views (through VBO or Rules Bonus Pack)
- That Rules configuration are actually entities
- How to disable reaction rules
Additional resources
Rules guide (Drupal.org)
This series on Learning the Rules framework was produced by Johan Falk of nodeone.se, and it will present some basic and advanced usage of the Rules framework.
The Rules module helps decrease the need for custom coding. Johan starts with an empty sandbox site. He enables the 3 related Rules modules, and the modules they depend on. Now, we see what it can do for our site by creating some reaction rules. This isn’t just an introduction – you actually get into the mechanics of using Rules right away.
Additional resources
- Rules module — Drupal.org
- Rules guide (Drupal.org)
Provides an overview of what is covered in the Theming Basics series and gives a preview of what is yet to be covered within the Advanced Theming video.
Walks through the process of adding a screenshot to you theme so that it'll show up properly within the theme administration page, following the screenshot directions found on Drupal.org, and using the Skitch screenshot app (you can use whichever screenshot app you like).
Additional resources
Takes a tour through some of the more useful template variables, and more ways of determining the available variables by adding the following code to a page template:
Walks through the process of first adding the search block to the node template file, and then explains some of the best practices for incorporating JavaScript scripts within your theme. Walks through how to protect the dollar-sign variable, and how to use the Drupal behaviors instead of the document ready so that your JavaScript will fire not only on page loads, but also if there is any dynamic material being loaded on the page through asynchronous page loads. We'll show you how to select the jQuery selector to target the desired element, and how to conform to Drupal's best-practice coding standards when it comes to integrating JavaScript and jQuery into your theme. You can learn more about jQuery itself with the Introduction to jQuery Series.
To use Query in no conflict mode, because was not defined.
Add this line on the top: jQuery.noConflict(); more info here: http://api.jquery.com/jQuery.noConflict/
To improve how the search box looks, you need to modify the following:
currently : search-theme-form
modify to: search-block-form
and then in the property in line 321 to look like this:
/* Header quick search */
#header form#search-block-form {
top: -165px;
Additional resources
Walks through the process of enabling the theme developer module and showing the themer info, which is like Firebug for Drupal theming. You can choose specific elements on the page to see what Drupal template files or theme functions were involved with outputting it to the screen. You can easily look at the candidate template names that are available, as well as see all of the variables that are available from that template file. A list of documented variables can be found within the node module's node.tpl.php file, but sometimes there are undocumented variables that are coming from contributed modules or elsewhere. It's a super handy tool to have available, but only enable it when you really need it since it can adversely affect the mark-up on your page and cause some wonky behavior.
Additional notes:
The Theme Developer module is on Drupal.org at http://drupal.org/project/devel_themer. Once you find a module on Drupal.org, you can see the "machine name" for the module in the URL (it is the same name as is used to for the module's .info file as well). That is the name that Drush uses. So, in this instance, Drush is looking for "devel_themer".
drush dl devel_themer