Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

The Twig Backlink extension builds a list of URL of the parents of the node based on the field name passed in the Twig twig_backlink extension parameter.

This extension will automatically build a list of parents when an Entity Reference field is used and referenced in the Twig file.

Usage

{{ twig_backlink('field_name') }}

You may wrap the twig_backlink extension with some verification to prevent PHP notices/warnings when there is no relation between a child and parent node:

{% set backlinks = twig_backlink('field_example') %}
{% if backlinks is defined %}
  {% if backlinks is not null %}
    {{ twig_backlink('field_example') }}
  {% endif %}
{% endif %}

Example

We may have two content types:

- Movie (with an Entity Reference field linked to Actor with machine name field_actors); this content type is the parent.
- Actor; this content type is the child.

In the node twig file of actors, we want to list all movies (parents) that the actor appears in automatically. So we add in the twig file:

{{ twig_backlink('field_actors') }}

We create a few actors and then for each movie we create, we reference the cast (actors) in the Actors field.

When viewing an actor node, all the movies the actors appears in will be displayed in a bulleted list of links pointing back to the movies the actor is staring in.

Requirements

- PHP ext-intl
- An Entity Reference field added to a node.
- Access to a node twig file that the themer can edit.

Soutien technique également offert en français.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Nov 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
2.1.2 Stable Nov 16, 2024