Duplicate template suggestions

Created on 24 May 2017, over 7 years ago
Updated 31 May 2024, 4 months ago

Hello,
I want to custom the output of users with twig suggestion, but
I get the 2 times the suggestion "layout--onecol.html.twig" for the "One column" layout, so I can't use the "layout-onecol--user.html.twig" file for example...

๏ฟผExtract from the debug mode:

<!-- THEME HOOK: 'layout__onecol' -->
<!-- FILE NAME SUGGESTIONS:
   x layout--onecol.html.twig
   * layout-onecol--user--1.html.twig
   * layout-onecol--user-user-full.html.twig
   * layout-onecol--user-user.html.twig
   * layout-onecol--user-full.html.twig
   * layout-onecol--user.html.twig
   x layout--onecol.html.twig
   * layout.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/layout_discovery/layouts/onecol/layout--onecol.html.twig' -->

Do you hnoxw why ?

I use D8.3.2, layout_discovery, ds 8.x-3.0

-----

Further investigation shows that:

  1. This happens also for field node created, comments, links and the toolbar.
  2. This also happens without layout_discovery enabled.
๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Themeย  โ†’

Last updated about 2 hours ago

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance steveoriol Grenoble ๐Ÿ‡ซ๐Ÿ‡ท

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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 fallenturtle

    Sorry to necro-post, but I'm also having a similar issue as the OP. The ticket that this is marked as a duplicate seems to be about fields, not layout.

     THEME HOOK: 'layout__onecol' 
     FILE NAME SUGGESTIONS:
       x layout--onecol.html.twig
       * layout-onecol--node--2126.html.twig
       * layout-onecol--node-activity-inline-entity-form-view.html.twig
       * layout-onecol--node-activity.html.twig
       * layout-onecol--node-inline-entity-form-view.html.twig
       * layout-onecol--node.html.twig
       x layout--onecol.html.twig
       * layout.html.twig
    

    I don't see the duplicate when I dump the variables (in my .theme file via HOOK_theme_suggestions_layout_alter:

    ^ array:6 [
      0 => "layout__onecol"
      1 => "layout_onecol__node"
      2 => "layout_onecol__node_inline_entity_form_view"
      3 => "layout_onecol__node_activity"
      4 => "layout_onecol__node_activity_inline_entity_form_view"
      5 => "layout_onecol__node__2126"
    ]
    

    I want to use layout-onecol--node-inline-entity-form-view.html.twig but I can't because something is putting layout__onecol.html.twig back at the top of the list and its happening after the theme suggestions function so I can't override it from that end either.

    Using D9.5.9.

    Edit: Worked around it by switching to a DS layout where the issue didn't exist.

    I still see the duplicate, but its at least at the bottom so I can override it:

     THEME HOOK: 'ds_1col' 
     FILE NAME SUGGESTIONS:
       * ds-1col--node--2126.html.twig
       x ds-1col--node-activity-inline-entity-form-view.html.twig
       * ds-1col--node-activity.html.twig
       * ds-1col--node-inline-entity-form-view.html.twig
       * ds-1col--node.html.twig
       * ds-1col.html.twig
       * ds-1col.html.twig
    
    ^ array:6 [โ–ผ
      0 => "ds_1col"
      1 => "ds_1col__node"
      2 => "ds_1col__node_inline_entity_form_view"
      3 => "ds_1col__node_activity"
      4 => "ds_1col__node_activity_inline_entity_form_view"
      5 => "ds_1col__node__2126"
    ]
    
  • Status changed to Active 12 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia darvanen Sydney, Australia

    #14: @fallenturtle I don't think that's a necro-post, you raise a valid point.

    Anyone coming across this: a failing test would be a very good starting point to getting this fixed.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada jmunger

    Drupal 10.2.6, not using Display Suite.

    I have a similar issue with menus. I want to use the menu--main--sidebar-first.html.twig but it seems impossible beacause of the menu--main.html.twig duplicate at the top of the suggestions.

    <!-- THEME DEBUG -->
    <!-- THEME HOOK: 'menu__main' -->
    <!-- FILE NAME SUGGESTIONS:
       x menu--main.html.twig
       * menu--main--sidebar-first.html.twig
       x menu--main.html.twig
       * menu.html.twig
    -->
Production build 0.71.5 2024