Top Banner
Bumpy road of Drupal 7 How to build a fast content How to build a fast content management application management application
42

DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Aug 07, 2015

Download

Internet

Drupaltour
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Bumpy road of Drupal 7How to build a fast contentHow to build a fast content

management applicationmanagement application

Page 2: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

The forewordThe forewordWhat is Drupal?What is Drupal?

Page 3: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 4: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Who Uses Drupal?Who Uses Drupal?GovernmentGovernment

MediaMediaRetailRetail

FinanceFinanceIndustryIndustry

EducationEducationEntertainmentEntertainment

Page 5: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

One of: MediaOne of: Media

Page 6: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

ArchitectureArchitecture

Page 7: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Title of the articleTitle of the article

Title of the section #1Lorem ipsum dolor sit amet, consecteturadipiscing elit. Vivamus vel venenatis nunc.Praesent luctus auctor turpis nec cursus.Sed commodo feugiat ullamcorper. Title of the section #2Lorem ipsum dolor sit amet, consecteturadipiscing elit. Vivamus vel venenatis nunc.Praesent luctus auctor turpis nec cursus.Sed commodo feugiat ullamcorper. Title of the section #3 ...

Page 9: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Title of the articleTitle of the article

Title of the section #1Lorem ipsum dolor sit amet, consecteturadipiscing elit. Vivamus vel venenatis nunc.Praesent luctus auctor turpis nec cursus.Sed commodo feugiat ullamcorper.

Title of the section #2Lorem ipsum dolor sit amet, consecteturadipiscing elit. Vivamus vel venenatis nunc.Praesent luctus auctor turpis nec cursus.Sed commodo feugiat ullamcorper.

Title of the section #3 ...

Page 10: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Edit "Title of the article"Edit "Title of the article"

Title of Section Body of Section

Title of the section #1

Lorem ipsum dolor sit amet, consectetur adipiscingelit. Vivamus vel venenatis nunc. Praesent luctusauctor turpis nec cursus.

Title of Section Body of Section

Title of the section #2

Page 11: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 12: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

What solution is better?What solution is better?

Page 13: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Field CollectionField Collection

Entity API Entity API (Required)(Required)

Page 14: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Entity ReferenceEntity Reference

Entity API Entity API (Required)(Required)Entity Construction Kit (ECK)Entity Construction Kit (ECK)

Inline Entity FormInline Entity Form

Page 15: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

What aboutWhat aboutperformance?performance?

Page 16: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

View Content (for Anonymous)View Content (for Anonymous)

Page 17: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Entity Reference fasterEntity Reference fasterthan Field collectionthan Field collection

by by 25-59%25-59%

Page 18: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Possible problemsPossible problems1. Edit Content (Form Loading)1. Edit Content (Form Loading)

2. Save & View Content2. Save & View Content

Page 19: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Possible problemsPossible problems1. Edit Content (Form Loading)1. Edit Content (Form Loading)

2. Save & View Content2. Save & View Content

3. Revisioning3. Revisioning

Page 20: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

How make it faster?How make it faster?

Page 21: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

MultifieldMultifieldProvide a compound field solution for Drupal 7Provide a compound field solution for Drupal 7

Page 22: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

View Content (for Anonymous)View Content (for Anonymous)

Page 23: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

LimitationsLimitations

The sub-fields inside the multifield are limited toone valueCannot have a multifield inside another multifieldMore issue related to advanced field typesUnholy things to Field and Entity APIs

of the Multifieldof the Multifield

Page 24: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

KEEPKEEPCALMCALM

ANDAND

WRITEWRITECODECODE

Page 25: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Custom fieldCustom field

Field APIField API

Page 26: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 27: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

View Content (for Anonymous)View Content (for Anonymous)

Page 28: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Custom field fasterCustom field fasterthan Entity Referencethan Entity Reference

by by 25%25%

and faster Field Collectionand faster Field Collectionby by 43-6543-65%%

Page 29: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Another ways toAnother ways tooptimizeoptimize

Optimize Database Queries: enableEntity Cache, etc.Minimize of the structure: remove unused (HTML)elementsDivide the form: move out "hard" field(s)from the form

Page 30: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Divide the formDivide the form

Page 31: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Edit Edit "Title of the article""Title of the article"

Title

Body

References

Title of the some article

Lorem ipsum dolor sit amet, consectetur adipiscingelit. Vivamus vel venenatis nunc. Praesent luctusauctor turpis nec cursus.

Article 1

Article 2

Page 32: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Let's move References fieldLet's move References fieldout of the formout of the form

Page 33: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 34: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

1. $form['field_name']['#access'] = FALSE;

StepsSteps

Page 35: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

1. Create custom field widget ("empty" widget tohide form elements)

StepsSteps

Page 36: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 37: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

1. Create custom field widget ("empty" widget to hideform elements) 2. Build custom form to edit field's values and display(render) it on the Edit Node page

Create custom table and provide functionalityto save field's values into custom table

StepsSteps

Page 38: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

StructureStructureof the custom tableof the custom table

LegendLegendform_build_id - Form Build ID of the Node Edit formentity_id - Node IDrevision_id - Node Revision IDuser_id - User's ID who save value(s)values - Value(s) of the field (serialized)expired - Determine whether values are expired

form_build_id entity_id revision_id user_id values expired

Page 39: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

1. Create custom field widget ("empty" widget to hideform elements) 2. Build custom form to edit field's values and display(render) it on the Edit Node page

Create custom table and provide functionalityto save field's values into custom table

3. Provide validate (presave) function to set form values(of the References field)

StepsSteps

Page 40: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)
Page 41: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

ResourcesResources

https://www.drupal.org/project/entityhttps://www.drupal.org/project/eck

https://www.drupal.org/project/field_collectionhttps://www.drupal.org/project/multifieldhttps://www.drupal.org/project/examples

https://www.drupal.org/node/707832

Page 42: DrupalTour. Lviv — Bumpy road of Drupal7 (Pavel Shevchuk, EPAM)

Thank you!Thank you!

Pavlo ShevchukSenior Software Engineerhttp://drupal.org/u/pshevchuk