Rules - Yaroslav Doroshuk

Post on 08-May-2015

1.364 views 0 download

Transcript of Rules - Yaroslav Doroshuk

Rules

Yaroslav Doroshuk

http://donetsk.drupal.ua

Ruleshttp://drupal.org/project/rules

Data selection

Loops

Examples

Mark as spam• Flag (Mark as spam)• Rules:oUnpublish spam commentoBlock spammeroNotify moderator about bad user

• Messages in spam log 

Moderators' workflow• Fields:oModeration status fieldoUnpublish date field

• Fields permission • Rules for publishing and notification.• VBO and Rules for bulk operations• Message module for logging changes 

Demo

Useful modules:

Rules Bonus Packhttp://drupal.org/project/rb

Aditional triggers, actions and conditions.

Views Bulk Operationshttp://drupal.org/project/views_bulk_operations

Run Your rules on the views-result.

Flaghttp://drupal.org/project/flag

Trigger rules on flag/unflag any item.

Rules Linkhttp://drupal.org/project/rules_link

Create links which trigger rules.

Page Managerhttp://drupal.org/project/ctools

User rules conditions to check access for page.

Content Accesshttp://drupal.org/project/content_access

 Give role-based access to nodes with rules.

Relationhttp://drupal.org/project/relation

Work with related entities and create relations.

Difference in performanceRules Custom module

Update user's name after account was updated.

~177,57 ms ~174,35 ms

Update user's name after node was viewed.

~230,5 ms ~193,06 ms

*Measurement was made on page load

Difference in performance

What does it mean?• ~40 ms additional page execution time• ~3 ms additional queries execution time• ~17 additional exuquted queries• ~3,5 mb additional RAM usage.

Development• Provide your own ations and conditions using : 

o hook_rules_action_info() o hook_rules_condition_info() 

• Define entity properties using hook_entity_property_info of the entity API

•Use Rules because:Rules is flexibleRules is more clear for a customerRules intagrates with other modulesYou can easily move needed functionality using FeaturesClicking is faster that writing a code

Useful LinksCode exampels: http://drupal.org/project/rules_example

Documentation: http://drupal.org/node/878720Screencasts: 

http://nodeone.se/node/984http://london2011.drupal.org/conference/sessions/rules-way-life

http://www.youtube.com/watch?v=1itm3t0YMfw

Questions?

Yaroslav Doroshukemail: yarroha@gmail.comskype: yarrohatwitter: https://twitter.com/#!/yarrohablog: http://yarroha.name/