This recipe describes some extra Rules functionality added by the Rules Bonus Pack module. This module is a set of extensions and integrations with other modules to extend Rules to provide additional Events, Conditions, and Actions and also integrate with other modules, such as CTools.
In this example, we will act on the node view by modifying the page title to include the node's associated taxonomy terms.
Create a new rule configuration, set the Event to Node | Content is viewed.
Add a Condition, Entities | Entity has field, use node as the entity and select field_tags as the field to check for.
Add an Action, Rules Bonus: Miscellaneous | Set page title.
Use REPLACEMENT PATTERNS to modify the page title.
In this example we've used a custom action provided by the Rules Bonus Pack module. We tell Rules to act on a node view by modifying the node's title, if it has any tags associated with it. For safety, we could also add a Condition, Data | Data value is empty, set it to node:field-tags, and check Negate to make sure we only do that if the node actually has terms.
Rules Bonus Pack provides a number of essential extensions to the Rules framework. The following is a list of the main features:
CTools / Page manager integration: Rules Bonus Pack provides a bridge between the Page manager and Rules. It can provide an Event for viewing each custom page variant, which is useful when using Panels and Rules together.
Rules Bonus Pack also provides integration with the Page manager's Access control feature. We can create condition components that can be used by the Page manager to determine whether a user can access the custom page.
Blocks and Theme related Actions: Rules Bonus Pack provides various Block and Theme related Actions. By enabling Rules Bonus: Block and Rules Bonus: Theme modules, we get access to various Actions, such as, placing a block in a region based on a condition or adding a custom CSS class to the body.
These recipes target developers who wish to extend Rules with their own custom Events, Conditions, and Actions. We'll also learn how to provide new entity tokens for Rules to use, how to execute rule configurations in code, and how to provide default rule configurations in our custom module.
The code snippets in these recipes are for demonstration purposes only. They are intended only to explain a specific hook or functionality and do not always provide a generic solution to a problem.