SlideShare a Scribd company logo
Drupal GENT: Programmeren zonder code
Door Lennart Van vaerenbergh
https://www.drupal.org/u/lennartvv
de Rules module van Drupal
Overzicht
• Wat is Rules?
• Conditional Rules
• Components
• Views Rules
• Drupal Commerce toepassingen
• Custom Rules: Zelf triggers, conditions en actions
aanmaken
D7: Stop hooking, start Ruling
Wat is Rules?
Wat is Rules?
De Rules module laat site builders/developers toe
om conditionele acties uit te voeren op
voorkomende events.
Rules is de core module ‘Trigger’…
…on steroids!
Wat is Rules?
Wat is Rules?
Elke module kan zijn eigen events,
conditions en acties toevoegen aan Rules.
Via eenvoudige hooks kan je dit ook zelf
doen.
Wat is Rules?
Configuratie:
admin/config/workflow/rules
(Demo: melding bij inloggen / unpublish new
node / login redirect)
Conditional Rules
Conditional Rules
• Module: rules_conditional
• Wat?
– Staat toe om conditions toe te voegen in de
Rules Action. Out of the Rules box kunnen
conditions enkel aan het ‘Conditions’ blok
toegevoegd worden.
– Structuren als if/else, switch/case en while
kunnen gebruikt worden.
• (Demo: Melding bij inloggen)
Components
Components
• Onderdeel van Rules:
• Wat?:
– Net als een functie met input en output
parameters
– Herbruikbare Rule
– Kan opgeroepen worden in alle andere Rules.
• (Demo: block user en verstuur mail)
Views Rules
Views Rules
• Module: views_rules
• Wat?
– Een loop op basis van een
view.
– In elke iteratie kan een actie uitgevoerd worden.
– Een heel specifieke lijst kan via Views
aangeleverd worden (filters in Views ipv
conditions in Rules)
• (Demo: Loop over user names na login)
Views Rules
• Hoe?
– Maak een View aan met display type ‘Rules
– Configureer row variables (= de variables waar
Rules toegang tot heeft)
– Een ID als variable zorgt ervoor rules toegang
heeft tot volledig object
– Bij aanmaken van nieuwe Rule: klik op ‘Add
view loop’ om de view te selecteren
• (Demo: Loop over user names na login)
Commerce en Rules
Commerce en Rules
• Commerce steunt op rules om de workflow
van bestellingen te beheren.
• Customizen van Commerce => Rules
• (Demo: bestaande rules / gratis product toevoegen)
Custom Rules
Custom Rules
• hook_rules_event_info()
• hook_rules_condition_info()
• hook_rules_action_info()
• Toevoegen aan MODULENAME.rules.inc
Rules 101
• Ik vind bepaalde velden niet terug in de data
selector?!
– Voeg een condition toe ‘entity is of bundle’ of
‘entity is of type’ of ‘entity has field’
– Vervolgens komen de (vaak custom) velden ter
beschikking

More Related Content

Featured (20)

PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
PDF
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
PDF
Everything You Need To Know About ChatGPT
Expeed Software
 
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
PDF
Skeleton Culture Code
Skeleton Technologies
 
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
 
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
PDF
Getting into the tech field. what next
Tessa Mero
 
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
PDF
Introduction to Data Science
Christy Abraham Joy
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Christy Abraham Joy
 

de Rules module van Drupal

  • 1. Drupal GENT: Programmeren zonder code Door Lennart Van vaerenbergh https://www.drupal.org/u/lennartvv
  • 3. Overzicht • Wat is Rules? • Conditional Rules • Components • Views Rules • Drupal Commerce toepassingen • Custom Rules: Zelf triggers, conditions en actions aanmaken
  • 4. D7: Stop hooking, start Ruling
  • 6. Wat is Rules? De Rules module laat site builders/developers toe om conditionele acties uit te voeren op voorkomende events. Rules is de core module ‘Trigger’… …on steroids!
  • 8. Wat is Rules? Elke module kan zijn eigen events, conditions en acties toevoegen aan Rules. Via eenvoudige hooks kan je dit ook zelf doen.
  • 9. Wat is Rules? Configuratie: admin/config/workflow/rules (Demo: melding bij inloggen / unpublish new node / login redirect)
  • 11. Conditional Rules • Module: rules_conditional • Wat? – Staat toe om conditions toe te voegen in de Rules Action. Out of the Rules box kunnen conditions enkel aan het ‘Conditions’ blok toegevoegd worden. – Structuren als if/else, switch/case en while kunnen gebruikt worden. • (Demo: Melding bij inloggen)
  • 13. Components • Onderdeel van Rules: • Wat?: – Net als een functie met input en output parameters – Herbruikbare Rule – Kan opgeroepen worden in alle andere Rules. • (Demo: block user en verstuur mail)
  • 15. Views Rules • Module: views_rules • Wat? – Een loop op basis van een view. – In elke iteratie kan een actie uitgevoerd worden. – Een heel specifieke lijst kan via Views aangeleverd worden (filters in Views ipv conditions in Rules) • (Demo: Loop over user names na login)
  • 16. Views Rules • Hoe? – Maak een View aan met display type ‘Rules – Configureer row variables (= de variables waar Rules toegang tot heeft) – Een ID als variable zorgt ervoor rules toegang heeft tot volledig object – Bij aanmaken van nieuwe Rule: klik op ‘Add view loop’ om de view te selecteren • (Demo: Loop over user names na login)
  • 18. Commerce en Rules • Commerce steunt op rules om de workflow van bestellingen te beheren. • Customizen van Commerce => Rules • (Demo: bestaande rules / gratis product toevoegen)
  • 20. Custom Rules • hook_rules_event_info() • hook_rules_condition_info() • hook_rules_action_info() • Toevoegen aan MODULENAME.rules.inc
  • 21. Rules 101 • Ik vind bepaalde velden niet terug in de data selector?! – Voeg een condition toe ‘entity is of bundle’ of ‘entity is of type’ of ‘entity has field’ – Vervolgens komen de (vaak custom) velden ter beschikking