Jesus Larrubia
Web developer (Drupal)
A better way to define your entity displays
By: Jesus Larrubia (jlarrubia)
Group of elements making up its visual representation.
'content' property
Through Manage Display UI...
Avoid ALL these problems!
Text
entity_display.api.php
entity_display.api.php
"Repeating myself"
"Tedious"
"Incomprehensible chunks of code"
"This is speeder" ✓
"I've seen this before" ✓
"Cool, I just need GIT and deploy code" ✓
"I can define display by view mode or as I please!" ✓
What about non field elements belonging to the display of an entity?
hook_entity_view, hook_preprocess_<entity_type> - I don't think this promote good practices...
entity_display.api.php
entity_display.api.php
"Promote good practices" ✓
"I like to use Drupal standards" ✓
"I do know how to do this" ✓
"I don't need any new module!" ✓
"Promote good practices" ✓
"Structured code" ✓
"Incomprehensible chunks of code"
Bob (FE developer) could be happier
"The FE is still depending on the BE" ✖
node_full.display
node_full_resource.display
"This is real separation" ✓
"The FE power is finally mine!" ✓
entity_display.drush.inc
Standard system | Homepage ~90 rendered entities | Article post ~ 10 rendered entities |
---|---|---|
1st load |
19,457,294 microsecs 2,496,394 functions |
13,624,583 microsecs 2,037,376 functions |
2nd load | 3,978,053 microsecs 301,133 functions |
670,880 microsecs 88,941 functions |
3rd load |
1,850,830 microsecs 1,004,135 functions |
650,335 microsecs 87,835 functions |
Entity display system | Homepage ~90 rendered entities | Article post ~ 10 rendered entities |
---|---|---|
1st load |
20,005,274 microsecs 2,473,409 functions |
12,822,605 microsecs 2,045,176 functions |
2nd load | 1,901,408 microsecs 184,732 functions |
639,742 microsecs 90,634 functions |
3rd load |
1,923,898 microsecs 173,216 functions |
619,436 microsecs 88,810 functions |
+ ~20%
Cause: Drupal tries to load the display twice
Prepare field data prior to display.
field.attach.inc
+ ~0-5%
"That's better" ✓
Solution: Skip unneeded display load (standard)
entity_display.module
By Jesus Larrubia