Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Twig Backlink

Security covered Under active development 5 sites

Part of the Twig ecosystem · 43 projects

This Twig extension generates a list of links to parent nodes based on a specified entity reference field. It automatically creates a backlink trail, allowing you to display related content like a list of movies an actor appears in.

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.

Drupal 9–11

Ask your assistant about Twig Backlink

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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
6
Tracked since
Apr 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.1.2 Stable 9–11 Nov 16, 2024
2.1.2-beta5 Pre-release 9–10 Sep 4, 2023
2.1.2-beta4 Pre-release 9–10 Sep 4, 2023
2.1.2-beta3 Pre-release 9–10 Sep 4, 2023
2.1.2-beta2 Pre-release 9–10 Apr 21, 2023
2.1.2-beta1 Pre-release 9–10 Apr 21, 2023