"Entity display plugin" is a powerful and flexible alternative to entity view modes.

Advantages compared to view modes:

  • The same entity display plugin, unlike a view mode, can be used across entity types and bundles.
  • Conditional logic can be implemented as plugins.
  • Entity display plugins, like other cfr plugins, are configuration-born behavior objects, and enjoy all the power of the cfrplugin ecosystem:
    • Entity display plugins can be nested, wrapped and combined.
    • One cfr plugin can act as a parameter for another plugin.
    • Different cfr plugin types can be used together.
    • Modern, "S.O.L.I.D." OOP code with injected dependencies, PSR-4 namespace directories, composition over inheritance.
    • Custom plugins are very easy to write. There is even a code generator, so a lot of time it is just copy+paste!
  • Entity display plugins do not pollute your field instance settings! (e.g. when exporting with features)
  • Entity display plugins are easier to maintain than view modes.
  • Entity display plugins likely have a performance advantage over entity view modes, because because they do not trigger the full entity render apparatus. (someone should profile this!)

Entity displays can also be used within entity view modes, via Entity display for field UI (currently a sandbox module).

Screencast: https://www.youtube.com/watch?v=AejsIbZO2MI

Technically, entity display plugins are cfr plugins for the EntityDisplayInterface interface from renderkit.

These plugins are exposed in different places in Drupal:
- As a views row plugin.
- As a views field plugin.
- As a field formatter for field types where entities are references. Currently entityreference, taxonomy_term_reference, paragraphs, field_collection.

- As a ctools content pane ("content_types" plugin).

Also see Entity display for Field UI sandbox module, which integrates entity displays in field UI, with or without display suite.

Try entdisp_example for a demo.


drush dl cfr
drush en -y entdisp

The only "special" thing here is that the cfr module package needs to be downloaded manually, because it does not contain a module with the same name as the package.
The other dependencies (incl composer packages) will be downloaded automatically with drush en -y entdisp.

Recommended: Cfr preset.
drush en -y cfrpreset

Project Information