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

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

Embed Size (px)

Citation preview

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

management applicationmanagement application

The forewordThe forewordWhat is Drupal?What is Drupal?

Who Uses Drupal?Who Uses Drupal?GovernmentGovernment

MediaMediaRetailRetail

FinanceFinanceIndustryIndustry

EducationEducationEntertainmentEntertainment

One of: MediaOne of: Media

ArchitectureArchitecture

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 ...

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 ...

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

What solution is better?What solution is better?

Field CollectionField Collection

Entity API Entity API (Required)(Required)

Entity ReferenceEntity Reference

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

Inline Entity FormInline Entity Form

What aboutWhat aboutperformance?performance?

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

Entity Reference fasterEntity Reference fasterthan Field collectionthan Field collection

by by 25-59%25-59%

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

2. Save & View Content2. Save & View Content

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

2. Save & View Content2. Save & View Content

3. Revisioning3. Revisioning

How make it faster?How make it faster?

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

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

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

KEEPKEEPCALMCALM

ANDAND

WRITEWRITECODECODE

Custom fieldCustom field

Field APIField API

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

Custom field fasterCustom field fasterthan Entity Referencethan Entity Reference

by by 25%25%

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

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

Divide the formDivide the form

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

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

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

StepsSteps

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

StepsSteps

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

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

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

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

Thank you!Thank you!

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