Entity reference back-fill formatter
19 sites
Security covered
This module provides a field formatter for entity reference fields that automatically populates with related content if the field is not fully set. It prioritizes content that shares the most matching terms with the current item, offering configuration options for display and matching logic.
About this module
Provides a field formatter for entity reference fields that allows back-filling values when a field is not completely populated by finding content with matching terms.
Items with the most matching terms are shown first.
The formatter allows you to configure:
- the view-mode used to render the related items;
- the quantity of items to display (up to the field maximum); and
- which vocabularies to give precedence to when selecting matching terms
- match mode for vocabularies (any/all/all with fallback)
Features
- Supports any entity-reference field where the target type is a content-entity
Use Cases
Add a 'related articles' field that allows curation but with a fallback if not populated
Demo
Evaluate this project online using simplytest.me.
Requirements
- Requires the Taxonomy entity index module.
- PHP 7
- Drupal core 8.7.7+
Installation
composer require "drupal/backfill_formatter"- Enable the module using drush or in 'Extend'. (/admin/modules)
- Find a content-type or entity you want to use the formatter on and visit its 'Manage display' page
- Select the 'Back-fill by terms' formatter and configure as required.
Known Issues/Limitations
- Layout builder won't show empty fields that use this formatter, apply the patch from #3067982: Formatters for empty fields do not render with layout builder enabled
- Tests won't pass until #3104318: Create tests and a config schema for taxonomy_entity_index.settings is merged
Please use the issue queue to report issues.
Similar modules
- Similar by terms - however this uses a blocks based approach and only works with nodes.