Title field only seems to render when Field Layout (core) module is enabled

Created on 30 August 2022, about 2 years ago
Updated 3 November 2023, about 1 year ago

Problem/Motivation

Title field only seems to render when Field Layout (core) module is enabled.

Steps to reproduce

  1. Install this module. The title field is now configurable at the managed displays
  2. Pick a node go to the settings and go to manage display settings,
  3. Set the title field en save the display.
  4. Make sure you use content.title in your node.html.twig.
  5. Go to a content page from the node you picked
  6. content.title is not rendered in the node (twig) template.

Using this module assumes me that I don't need the Field Layout (core) module. This because it is displayed in the managed display.
When I enable the Field Layout (core) module, the title is rendered at the content page.

To make things clear. This is not about the title field that you can insert via a block in the layout block interface. This is about the title variable in the node twig template.

Proposed resolution

Make sure the title variable in the node template is rendered when configured at the node views display.

Remaining tasks

A clear test case to reproduce the bug.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands

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.

  • πŸ‡ΊπŸ‡ΈUnited States srdtwc Skokie, IL

    I can also confirm this same behavior. That said, It does not always appear to be the case though. A colleague of mine tried reproducing this issue on a fresh install of Drupal 9 and he was unable to. I've tried removing all twig templates, custom javascript, and theme hooks from my custom theme to isolate potential sources of this issue and the behavior has remained the same.

    When I enabled field_layout it works fine, but that breaks other aspects of my custom theme.

    I believe this requires further investigation.

  • πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands

    Just a brain fart looking into the render array. Could the #acccess key causing the problem ?

  • πŸ‡ΊπŸ‡ΈUnited States srdtwc Skokie, IL

    I do not see #access when I go to /devel/render/. Am I looking in the right place?

  • πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands

    {{dump (content.title)}}

    ^ array:19 [β–Ό
      "#theme" => "field"
      "#title" => Drupal\Core\StringTranslation\TranslatableMarkup {#2391 β–Ά}
      "#label_display" => "hidden"
      "#view_mode" => "full"
      "#language" => "nl"
      "#field_name" => "title"
      "#field_type" => "string"
      "#field_translatable" => true
      "#entity_type" => "node"
      "#bundle" => "page"
      "#object" => Drupal\node\Entity\Node {#1373 β–Ά}
      "#items" => Drupal\Core\Field\FieldItemList {#4303 β–Ά}
      "#formatter" => "title"
      "#is_multiple" => false
      "#third_party_settings" => []
      0 => array:3 [β–Ά]
      "#cache" => array:3 [β–Ά]
      "#weight" => 1
      "#access" => false
    ]
  • πŸ‡ΊπŸ‡ΈUnited States srdtwc Skokie, IL

    file: node--event--full.html.twig

    {{dump (content.title)}}

    array:19 [
    β–Ό
    
      "#theme" => "field"
      "#title" => Drupal\Core\StringTranslation\TranslatableMarkup {
    #1642 β–Ά
    }
      "#label_display" => "hidden"
      "#view_mode" => "full"
      "#language" => "en"
      "#field_name" => "title"
      "#field_type" => "string"
      "#field_translatable" => true
      "#entity_type" => "node"
      "#bundle" => "event"
      "#object" => Drupal\node\Entity\Node {
    #2157 β–Ά
    }
      "#items" => Drupal\Core\Field\FieldItemList {
    #6576 β–Ά
    }
      "#formatter" => "title"
      "#is_multiple" => false
      "#third_party_settings" => []
      0 => array:3 [
    β–Ά
    ]
      "#cache" => array:3 [
    β–Ά
    ]
      "#weight" => 0
      "#access" => false
    ]
    
  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom adamps

    Basically this is what Drupal Core does. I think this is a duplicate of ✨ Allow node/entity to display title/label field as normal Needs work .

  • πŸ‡ΊπŸ‡ΈUnited States srdtwc Skokie, IL

    Could you explain more what you mean by that? I am have some trouble understanding what the root cause of this issue is, but I was able to work around the problem in my particular case with the following:

    1. Installed 1.x-dev@dev
    2. Installed manage_display_fix_title
    3. Applied the patch here: https://www.drupal.org/project/manage_display/issues/3143678#comment-142... ✨ Allow node/entity to display title/label field as normal Needs work
    4. After that I had to modify a couple lines in manage_display_fix_title.module for PHP 8 compatibility.

    This does not seem like a great solution since it involves using an outdated version of the module a patch and some custom code. But maybe others will find this useful.

  • πŸ‡¦πŸ‡ΉAustria drupalfan2

    The Manage display still does not work. No title is show on node page (node/xxx).

    The patch #24 is not working!

    Actually the submodule manage_display_fix_title does only contain 1 file:
    manage_display_fix_title.info.yml

    A file manage_display_fix_title.module is missing!

    The Manage display module is unusable! I had to remove it. It does not work.

  • Status changed to Active about 1 year ago
  • Status changed to Postponed: needs info about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom adamps

    I notice in #7 and #8 that #access is false which would likely explain why the title is missing.

    Could you explain more what you mean by that?

    On a node page, Drupal Core takes the title out of the normal page display. The manage display settings have no effect, and this module has no effect. The title will show in the title block, but if you don't display that block you won't see any title.

    the submodule manage_display_fix_title does only contain 1 file:

    This is expected - the sub-module is obsolete now.

    Using this module assumes me that I don't need the Field Layout (core) module

    Correct, this module doesn't need the Field Layout module.

    The Manage display module is unusable!

    The module works fine for nearly 3000 sites - only a small number have a problem. I have can't reproduce this bug when I follow the steps to reproduce.

  • πŸ‡¦πŸ‡ΉAustria drupalfan2

    On a node page, Drupal Core takes the title out of the normal page display. The manage display settings have no effect, and this module has no effect. The title will show in the title block, but if you don't display that block you won't see any title.

    But on some sites and some pages we need to disable the tilte block and to show the title within the node (within the tag).
    This is exactly what this module is for.

    But the title within the node is not display, still if "Manage display" is configured correctly.

    And again: When the title (Manage display) is not show then this module is not usable.

    This is expected - the sub-module is obsolete now.

    Then please remove the submodule immediately to avoid confusion.

    The module works fine for nearly 3000 sites - only a small number have a problem. I have can't reproduce this bug when I follow the steps to reproduc

    Maybe 2900 sites are using an older version of this module.

    Please try to reproduce on a new Drupal installation.
    Please ask for further information if you can not reproduce.

  • πŸ‡¬πŸ‡§United Kingdom juc1

    I have the same problem
    new / clean D10.1, Olivero theme,
    enable manage_display
    New title field shows in /admin/structure/types/manage/page/display
    but new title field does not show on /node/1 after reload page, clear cache
    enable field_layout
    reload /node/1 - now new title field displays

    I dont really want to enable field_layout if not necessary because it causes problems for me elsewhere

  • πŸ‡¬πŸ‡§United Kingdom adamps

    I understand that for a few people it doesn't work.

    But for most of us it does, and I don't know how to reproduce the bug. So the next step is for somebody who is seeing the bug to work out what conditions cause it to appear. Maybe it depends on the theme, on the block settings, on the templates, etc.

  • πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands
  • πŸ‡¬πŸ‡§United Kingdom adamps

    I don't see a title variable. Do you mean label? Or content.title?

    When using this module label will be blank. This is working as designed and is the whole point of the module.

    content.title will be set based on manage display settings.

  • πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands

    yes I meant content.title. sorry for the confusing.

    I didn't check this recently, will try to do it this week and come back at it.

  • πŸ‡¬πŸ‡§United Kingdom adamps

    NB #9
    Basically this is what Drupal Core does. I think this is a duplicate of ✨ Allow node/entity to display title/label field as normal Needs work

    More explanation in #13

    On a node page, Drupal Core takes the title out of the normal page display. The manage display settings have no effect, and this module has no effect. The title will show in the title block, but if you don't display that block you won't see any title.

  • Status changed to Closed: duplicate about 1 year ago
  • πŸ‡³πŸ‡±Netherlands Martijn de Wit πŸ‡³πŸ‡± The Netherlands

    Agree lets discus it further at ✨ Allow node/entity to display title/label field as normal Needs work

  • πŸ‡¬πŸ‡§United Kingdom juc1

    > Maybe it depends on the theme, on the block settings, on the templates, etc.

    @AdamPS I have the same problem on multiple sites but for my test mentioned in #15 above it is a new / empty 10.1 site, default content types, no other modules enabled by me, Olivero theme, I have not touched block settings or template files.

Production build 0.71.5 2024