This project is not covered by Drupal’s security advisory policy.

Linked Entity Reference provides a new field type which has a combination of link and entity reference capabilities. It lets you relate an entity with an arbitrary URL.

Motivation

In most situation entities are linked to the entity page (or to the file URI in case of media), but there are many situations where entities need to be linked to a different URL (internal or external).

One option is to add a link field to that entity plus some custom coding/theming to make that link as a wrapper to the entity, but that approach has a limitation: the link is part of the entity, so you can not link the same entity to different URLs on different situations. With this module, the URL is part of the field tha tlinks to the entity, so you can reference an entity and give it a URL to the link at field item level. URL's are always optional.

Important note for Drupal core less than 9.4.x

Apply patch from #3173770: Allow field types extending entity_reference to use field widgets extending media_library for the module to work properly.

Use cases

There are many situations where this module can be used:

  • Real state features from a fixed collection linking them to pictures.
  • Select skills on a CV linking them to external resources.
  • Link media items to any page
  • Link reusable teasers...

Installation

  • Install the module with composer
    composer require drupal/linked_entity_reference
    
  • Apply the patch on #3173770: Allow field types extending entity_reference to use field widgets extending media_library to drupal/core with Composer if you are using Drupal prior to 9.4.0.
  • Enable the module.
    drush en linked_entity_reference
  • Add a field of type "Linked entity reference" to a fieldable entity bundle, such as node type, block type, etc.
  • Configure the form display. There are 2 widgets provided:
    • Autocomplete: Supported when referencing all entity types.
    • Media library: Supported when referencing media entities.
  • Configure the view display. There are 2 field formatters provided:
    • Label
    • Rendered entity

    Both work as their entity reference equivalent field formatters.

Supporting organizations: 
Maintainer organization

Project information

Releases