Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows you to create custom tokens that can access data from related entities, even across multiple levels of connections. It's useful for building dynamic content, breadcrumbs, or URLs based on deeply nested entity information.

Entity Deep Token

Provides customizable tokens to recursively access fields of related entities.

This module defines a new token type called `entity_deep_token`, which allows you to traverse relationships between entities (such as nodes) and access properties like ID, label, bundle, or raw field values, even across multiple levels of depth.

Purpose

By default, Drupal’s token system only supports direct (one-level) relationships. This module enables token-based access to deeply nested related entities, which is particularly useful for:

  • Hierarchical breadcrumbs generation.
  • Metadata generation based on related entity values.
  • Custom URL building and conditional logic.

Installation

Install the module via Composer:

composer require drupal/entity_deep_token

Enable it via the admin interface or Drush:

drush en entity_deep_token

How to Use

The module adds a new token type: entity_deep_token. It works in any entity context (e.g., node) and allows you to traverse entity reference chains using a structured syntax.

General Syntax

[entity-deep-token:<field>:entity:<field>:entity:<property>]

  • <field>: Name of the entity reference or other field.
  • entity: Indicates traversal to the referenced entity.
  • <property>: Values like id, label, bundle, value, target_id, etc.

Example 1:

degree node → department → school

Entity relationship:

degree → field_department → department → field_school → school

Get the school node ID:

[entity-deep-token:field_department:entity:field_school:entity:id]

Get the school node title:

[entity-deep-token:field_department:entity:field_school:entity:label]

Get the school node bundle:

[entity-deep-token:field_department:entity:field_school:entity:bundle]

Example 2: Get raw creation date from a related entity

Suppose you have an entity reference field field_related_node and you want the creation timestamp:

[entity-deep-token:field_related_node:entity:created:value]

Limitations

Only works when in an entity context (node, user, taxonomy_term, etc.).

Does not yet support multiple values in reference fields (only the first item is accessed).

Does not format raw values (e.g., timestamps are not human-readable).

Future Ideas

  • Support multiple field values (e.g., 0, 1, etc.)
  • Support date formatting via date:format
  • Better integration with the Token UI (autocomplete suggestions)

Maintenance

This module is experimental but stable. Contributions, bug reports, and feature requests are welcome.

Activity

Total releases
5
First release
Jun 2025
Latest release
11 months ago
Releases (12 mo)
2 ▼ from 3
Maintenance
Slowing

Release Timeline

Releases

Version Type Release date
1.0.3 Stable Jul 25, 2025
1.0.2 Stable Jul 24, 2025
1.0.1 Stable Jun 26, 2025
1.0.0 Stable Jun 25, 2025
1.0.x-dev Dev Jun 25, 2025