Хуки, токены, рулсы, плагины - пишем "правильный" код под...

15
S Hooks, tokens, rules, elements, plugins Developing for Drupal the “right” way “I know a way” (c) Saul Berrenson

Transcript of Хуки, токены, рулсы, плагины - пишем "правильный" код под...

Page 1: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

S

Hooks, tokens, rules, elements, plugins

Developing for Drupal the “right” way“I know a way” (c) Saul Berrenson

Page 2: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

Tokens

Expose your module information to other modules

Examples HybridAuth and uLogin modules use it to expose

social information

Page 6: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

Rules

Rules are ruling

Power and flexibility

Examples HybridAuth and uLogin Yandex Webmaster Original Texts

Page 7: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

Views Bulk Operations

Batch API

Queue

Very useful for content manipulations

You just need to code the actual changes

Page 8: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

What a plugin is?

Array of properties utilized by another module

Properties may be function callbacks

Page 11: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

S

Most popular content

Module design example

Page 12: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский
Page 14: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

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

Page 15: Хуки, токены, рулсы, плагины - пишем "правильный" код под Друпал - Андрей Березовский

Thank you!

[email protected]