Add theme hook suggestions

Created on 24 October 2018, about 6 years ago
Updated 20 June 2024, 5 months ago

Problem/Motivation

Currently, the module provides a Twig template that can be overridden by modules and themes. However, they can only do so if they keep the exact same filename as the one used by the module. This makes it complicated to provide different templates for different instances of the field.

Proposed resolution

Provide multiple theme hook suggestions that will allow the field template to be overridden. The used suggestions could be similar to the ones provided by the Drupal core fields:

FILE NAME SUGGESTIONS:
   * field--node--[field-name]--[node-type].html.twig
   * field--node--[field-name].html.twig
   * field--node--[node-type].html.twig
   * field--[field-name].html.twig
   * field--[field-type].html.twig

Remaining tasks

Create a patch that implements hook_theme_suggestions_HOOK() and adds multiple file name suggestions.

User interface changes

None.

API changes

None for existing installations. When the proposed solution is applied, developers will have the ability to make template overrides more specific.

Data model changes

None.

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇳🇱Netherlands Dimiter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024