hooks, tokens, rules, elements, plugins developing for drupal the “right” way “i know a way”...
TRANSCRIPT
![Page 1: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/1.jpg)
S
Hooks, tokens, rules, elements, plugins
Developing for Drupal the “right” way“I know a way” (c) Saul Berrenson
![Page 2: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/2.jpg)
Who am I?
Head of Web-development for Axel Springer Russia
Author of 20+ contrib modules
Maintainer of several other contrib modules
Module application reviewer
Recently a father to a cute daughter Anastasia
![Page 3: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/3.jpg)
Plan first, code second
You should know the code flow before writing anything
Plan for flexible and light architecture
Think about exposed APIs your module would need
![Page 4: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/4.jpg)
Utilize Drupal’s best parts
Drupal is really good in text filtering, but only server-side (PHP code)
Paste Format uses Drupal text filtering features to filter the pasted text (and you rule what actually gets filtered and what stays in your content)
![Page 5: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/5.jpg)
Tokens
Expose your module information to other modules
Examples HybridAuth and uLogin modules use it to expose
social information
![Page 6: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/6.jpg)
Rules
Rules are ruling
Power and flexibility
Examples HybridAuth and uLogin Yandex Webmaster Original Texts
![Page 7: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/7.jpg)
Views Bulk Operations
Batch API
Queue
Very useful for content manipulations
You just need to code the actual changes
![Page 8: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/8.jpg)
Elements
Easy to reuse in any renderable array
#properties to control your element
Study drupal_render() to understand the rendering flow
‘#pre_render’ is really powerful
![Page 9: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/9.jpg)
Plugins
Views, Panels use it – and you should
Flexible architecture
Eases maintenance and support (Image Editor)
Allows other developers to extend your module
Drupal 8 does the same
![Page 10: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/10.jpg)
What a plugin is?
Array of properties utilized by another module
Properties may be function callbacks
![Page 11: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/11.jpg)
S
Most popular content
Module design example
![Page 12: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/12.jpg)
Most popular content
Always fresh statistics
By day, week, month
By content section on our site
No load on our servers
Is there a module for that?
![Page 13: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/13.jpg)
![Page 14: Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson](https://reader030.vdocument.in/reader030/viewer/2022032804/56649e4e5503460f94b44473/html5/thumbnails/14.jpg)
Statistics provider
(plugins?)Popular URLs
URLs processor(plugins)
Popular entities(nodes, terms, you name it)
Views integration(Views handlers)
Any widget design
https://www.drupal.org/sandbox/chyvakoff/2370095