Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to the Module

Similar presentations


Presentation on theme: "Introduction to the Module"— Presentation transcript:

1 Introduction to the Module
Rules Introduction to the Module

2 Rules - https://www.drupal.org/project/rules
Introduction Rules - Triggers (events) and actions, with conditions Coding with a UI More advanced version of the core Trigger module

3 Uses Solve problems on your site (custom modules)
Create automated systems (scheduled or triggered) Re-use functionality Integrate with VBO, Commerce

4 Rules Breakdown 1 Events, Conditions, Actions

5 Rules Breakdown 1—Events, Conditions, Actions
Events determine which entities are available to the rule. Some events also provide special conditions and actions. EVENTS “When” Defined triggers Determine which entities are available in the rule CONDITIONS Entities provide variables (e.g. fields). “If” Help narrow down/fetch specific entities ACTIONS Variables are used in conditions and actions. “Then” Can also be used to fetch entities

6 You found a Pikachu! Create a Basic Rule

7 You found a Pikachu!—Setup
GOAL Display a Pikachu on authenticated users’ account page MODULES Rules File Entity SET UP Upload an image of Pikachu Add an image field to the user account page

8 You found a Pikachu!—Rule Creation
Rule type: Rule Event: User account page is viewed Better option: User is created Condition: User has role(s) Authenticated user Action: Set a data value Field: account:[image-field]:file Value: image file ID (fid) Create actions Define conditions Choose event Determine rule type

9 Rules Breakdown 2 Components, Data Types, Parameters

10 Rules Breakdown 2—Components, Variables
Events determine entities. Sub-rules Don’t require events Do require variables to be passed to them Allow you to add more conditions, form complex rule chains Entities provide variables. VARIABLES Variables are also used by components. The pieces of data the component will use Will be provided by the entity in the main rule Connections

11 Pick Your Pokémon Create a Layered Rule

12 Pick Your Pokémon—Setup
GOAL Display the correct Pokémon on the user’s account page SET UP Upload two more Pokémon images Create three roles NOTE This Rule assumes you have created a way for users to be sorted into roles – like creating a field on the registration form that allows users to choose their team (role).

13 Pick Your Pokémon—Rule Creation
Rule type: Rule Set Event: User account page is viewed Condition: -- Components: Three almost identical rule components Create components Choose event Determine rule type

14 Pick Your Pokémon—Component Creation
Component type: Rule Set Condition: User has role(s) Action: Set a data value Field: account:[image- field]:file Value: image file ID (fid) Add components to main rule Create actions Define conditions Determine component type

15 Rules Breakdown 3 Lists, Loops

16 Rules Breakdown 3—Lists, Loops
Multi-value fields Example: Taxonomy LOOPS Affect each value in the list PHP For Loop Work well with components

17 Rules Breakdown 3—Examples from BYU Studies
On Journal Publishing Loops + components When a journal is published (a new journal product is created), expires subscribers, sends out s. On License Activation, Set Expiration Issue Number Components When a customer buys or renews a subscription, the expiration issue is set

18 Tips and Tricks Use “Entity is of type” and “Entity has field” conditions to use custom fields in actions Use “Fetch entity by ID” and “Fetch entity by property” actions to bring in another entity or access entities that are not provided by events If using Commerce, clone their rules. Also, the Stock module allows you to modify the Add to Cart form with rules. Use the debug option! Configuration > Workflow > Rules > Settings > Show debug info (always [when testing – turn in off after]) To ensure that an entity has just changed, use two conditions Data comparison changed/updated status = [whatever state] Data comparison unchanged status NOT = [same state]

19 Resources Tutorial Links

20 Tutorials Drupalize.me Other Resources
Introduction to Rules - Or Drupal 7 – All About Rules - Coding for Rules - Other Resources Test Drupal online - Pokémon images from Wikipedia


Download ppt "Introduction to the Module"

Similar presentations


Ads by Google