"Entity display plugin" is an alternative to entity view modes, based on renderkit EntityDisplay* components.

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

Benefits

Benefits for a site builder:

  • The same entity display plugin, unlike a view mode, can be used across entity types and bundles (node types, vocabularies, product types etc).
  • Unlimited nesting, composition and repetition: One EntityDisplay configuration can contain other EntityDisplay configurations. The same field can be displayed in more than one place within the EntityDisplay component.
  • Conditional elements: Show different content depending on an EntityCondition component.
  • Fallback behavior: If one element turns out empty (e.g. no field content), show another element instead!
  • Elements from related entities: Show the author picture for a node, or show referenced entities.
  • Wrappers and processors: Wrap some content into a link, or into a container with background image.
  • Integration of all or most common Drupal elements you might want to display: Fields, views, blocks, etc.

Developer experience (DX):

  • Export your configurations with features.
  • Split your configurations into reusable presets, if they become too complex.
  • Easily create your own components in a custom module, simply by writing annotated PHP classes in a PSR-4 directory structure.
  • Write your custom components in a generic/reusable way, then use configuration to parameterize them with site-specific field names, bundle names etc.
  • It combines very nicely with CSS components, custom theme hooks, and custom render element types!

What's wrong with traditional view modes?

  • They pollute your field instance settings, e.g. when exporting with features.
  • They need a separate configuration per bundle (e.g. node type, taxonomy vocabulary, product type..), even if you want mostly the same appearance and behavior for each bundle.
  • Limitations: Items in a view mode are mostly a flat list (plus field groups and layout regions). Existing solutions for conditions, nesting or integration of related entities are limited and complex.
  • Performance: View modes tend to be slower than entdisp/renderkit components.

EntityDisplay components can also be used within entity view modes, via Entity display for field UI.
Likewise, entity view modes can be used within EntityDisplay components.

Integration

entdisp integrates EntityDisplay* components 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.

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

Installation

entdisp requires cfr, which requires some Composer libraries.
These can be installed either with composer_manager or with drupal-composer or something equivalent.

Instructions can be found on https://www.drupal.org/project/cfr

Project information

  • Created by donquixote on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    Look for the shield icon below.

Releases