Wrong "custom" view mode in template suggestions

Created on 11 March 2021, over 3 years ago
Updated 18 June 2024, 10 days ago

Problem/Motivation

The template suggestions have a "custom" view mode. It would be nice to have the correct view mode in the template suggestions.

Steps to reproduce

<?php

namespace Drupal\example\Plugin\ExtraField\Display;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\extra_field\Plugin\ExtraFieldDisplayFormattedBase;

/**
 * Extrafield formatter.
 *
 * @ExtraFieldDisplay(
 *   id = "node_type",
 *   label = @Translation("Node type"),
 *   bundles = {
 *     "node.*"
 *   }
 * )
 */
class NodeType extends ExtraFieldDisplayFormattedBase {

  /**
   * {@inheritdoc}
   */
  public function viewElements(ContentEntityInterface $entity) {
    return [
      '#markup' => $entity->type->entity->label(),
    ];
  }

}

Suggestions:

<!-- FILE NAME SUGGESTIONS:
   * field--node--extra-field-node-type--article---custom.html.twig
   * field--node--extra-field-node-type---custom.html.twig
   * field--node--extra-field-node-type--article.html.twig
   * field--node--extra-field-node-type.html.twig
   * field--node--article.html.twig
   * field--extra-field-node-type.html.twig
   * field--extra-field.html.twig
   x field.html.twig
-->

Suggestions should be, with a "alert" view mode:

<!-- FILE NAME SUGGESTIONS:
   * field--node--extra-field-node-type--article---alert.html.twig
   * field--node--extra-field-node-type---alert.html.twig
   * field--node--extra-field-node-type--article.html.twig
   * field--node--extra-field-node-type.html.twig
   * field--node--article.html.twig
   * field--extra-field-node-type.html.twig
   * field--extra-field.html.twig
   x field.html.twig
-->
✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France GuillaumeDuveau Toulouse

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

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.69.0 2024