Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MXT created an issue. See original summary.

MXT’s picture

Issue summary: View changes
MXT’s picture

FileSize
860 bytes

Here's the patch.

aspilicious’s picture

Status: Active » Needs review

Hmm, I wonder what this solution does when u use it when using page manager or panels.

Status: Needs review » Needs work

The last submitted patch, 3: ds-2887778-3-D8.patch, failed testing. View results

gambry’s picture

Worth mentioning suggestions do work, there are just few new - and undocumented - rules to follow.

See comments from #26 to #29 on #2862683: 'base hook' key prevents template suggestions from working for research and examples.

gavrochelegnou’s picture

Hello,
I am having this issue.
My themes overrides that worked on 8.2 does not work anymore on 8.3.
I tried this change

is_a($info->getClass(), \Drupal\Core\Layout\LayoutDefault::class, TRUE)

But it doesn't seem to change anything.

The first problem i had was that the DS theme files where not searched in the module but in the theme folder :

Twig_Error_Loader: Template "themes/fms_theme/templates/ds-1col.html.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "themes/fms_theme/templates/ds-1col.html.twig" in the Drupal theme registry.) in "modules/ds/templates/ds-entity-view.html.twig" at line 10. in Twig_Loader_Chain->getCacheKey() (line 115 of vendor/twig/twig/lib/Twig/Loader/Chain.php).

So i copied this file to my theme and the error was gone but my theme suggestions does not work, my file "ds-1col--node-article-actu-moyenne.html.twig" is not used anymore and ds-1col.html.twig is used instead

<!-- FILE NAME SUGGESTIONS:
   * ds-1col--node--48984.html.twig
   * ds-1col--node-article-actu-moyenne.html.twig
   * ds-1col--node-article.html.twig
   * ds-1col--node-actu-moyenne.html.twig
   * ds-1col--node.html.twig
   x ds-1col.html.twig
   x ds-1col.html.twig
-->

Is there a quick fix i could apply to get my theme back and update to 8.3 ?

gambry’s picture

Have you had a look at this?
https://manifesto.co.uk/upgrading-to-drupal-8-3/

Also https://www.drupal.org/node/2862683 has a bit of reasearch for getting layout templates and suggestions work properly.

gordon’s picture

FileSize
2.25 KB

I am having this problem, and I have come to the conclusion that the problem is the theme suggestions are being created incorrectly.

When Display Suite creates the suggestions, they are created using the layout id, which with the built in layouts the id and the template/theme hook are different. This is ok with the built in DS layouts.

So basically I have changed the logic that creates the suggestions to load the layout and get the theme hook to use and create the correct suggestions.

Martijn de Wit’s picture

Status: Needs work » Needs review

Triggered some test for the latest patch and change status issue

@gordon, your patch is completely different from https://www.drupal.org/files/issues/ds-2887778-3-D8.patch.
Can this old one set hidden?

mlncn’s picture

The Template Suggester module is currently working around this by replacing layout-onecol--node.html.twig layout template suggestions (one dash) with layout-onecol--node-full.html.twig (two dashes).

ccshannon’s picture

I'm having the issue @gavrochelegnou has/had, but in my case it's only an issue with an entity display called from within another entity display. In my case, i have a node type with a 'card' display using ds-1col layout. I created a custom theme template for ds-1col--node--card.html.twig and it is used by the theme. That's working.

Also, the template suggestions all appear to be correct.

But the 'author' of the content (the uid) I have set as a user Rendered Entity in my card display for the content type. That display is called 'badge' and also uses the ds-1col layout. I created the template ds-1col--user-badge.html.twig ... but the template is not being used. Instead, the ds contrib template 'ds-1col.html.twig' is being used.

If I create a preprocess function for '_preprocess_ds_1col__user_badge', clear cache and reload the display, I get a WSOD and the error logs show "Template "themes/custom//templates/ds-1col.html.twig" is not defined." as I did not copy the ds_1col.html.twig into my custom theme. If I copy that template into my custom theme, the WSOD goes away, but I cannot get the ds-1col--user-badge.html.twig file to ever be used.

I will work around this by creating a custom layout for the 'badge' display so it targets the proper template, and perhaps my 'nested' display settings are 'edge case' usage - therefore 'works as designed'? - but I thought I'd throw this out there if anyone sees it as an issue.

gordon’s picture

Hi the older patch as it is not needed and may just confuse things.

Martijn de Wit’s picture

Used this path with DS v3.3. I see no difference in suggestions that are printed.

not for the DS col templates and nor for the DS field template suggestions.

Only thing I notice is that it renders "default" as entity view in both cases but the display is set to "teaser".

rivimey’s picture

Thought I'd drop by and say I'm using patch #9 in production so the correct templates for my site are used. I believe it is good to go as a patch.

swentel’s picture

Version: 8.x-3.1 » 8.x-4.x-dev

Moving to 8.x-4.x first - going to investigate to fix this once and for all.

rivimey’s picture

Just checking in again... still using patch on D9.1, still happy.

Johan den Hollander’s picture

Status: Needs review » Reviewed & tested by the community

Before patching with #9.

FILE NAME SUGGESTIONS:
x layout--twocol-bricks.html.twig
* layout-twocol-bricks--node--23005.html.twig
* layout-twocol-bricks--node-lied-full.html.twig
* layout-twocol-bricks--node-lied.html.twig
* layout-twocol-bricks--node-full.html.twig
* layout-twocol-bricks--node.html.twig
x layout--twocol-bricks.html.twig
* layout.html.twig

After patching
FILE NAME SUGGESTIONS:
x layout--twocol-bricks.html.twig
* layout--twocol-bricks--node--23005.html.twig
* layout--twocol-bricks--node-lied-full.html.twig
* layout--twocol-bricks--node-lied.html.twig
* layout--twocol-bricks--node-full.html.twig
* layout--twocol-bricks--node.html.twig
x layout--twocol-bricks.html.twig
* layout.html.twig

ng: layout-twocol-bricks--node-lied-full.html.twig
ok: layout--twocol-bricks--node-lied-full.html.twig

So patch works well for me.

swentel’s picture

Version: 8.x-4.x-dev » 5.0.x-dev
swentel’s picture

Status: Reviewed & tested by the community » Closed (outdated)

I've killed template suggestions in 5.0.x, see also #3123311: Theming changes for 5.0.x. There are still problems with template suggestions in layout discovery anyway and I didn't want to deal with them anymore.

swentel’s picture

Status: Closed (outdated) » Active

Ok, so apparently we use this at work a lot, so this will stay in for 5.0.x :)

swentel’s picture

Status: Active » Needs review
FileSize
8.29 KB

Ok, updated patch; uses getThemeHook() and double hyphens everywhere to be consistent.

ds_theme_suggestions_alter also catches the exceptions and logs a message (which can be turned off in settings.php)

Status: Needs review » Needs work

The last submitted patch, 22: 2887778-22.patch, failed testing. View results

swentel’s picture

Status: Needs work » Needs review
FileSize
0 bytes
swentel’s picture

FileSize
8.45 KB

Uploading patch ...

  • swentel committed 2c57848 on 5.0.x
    Issue #2887778 by swentel, MXT, gordon: Template suggestions does not...
swentel’s picture

Status: Needs review » Fixed

committed and pushed, yay.

swentel’s picture

Status: Fixed » Closed (fixed)
swentel’s picture

Version: 5.0.x-dev » 8.x-3.x-dev
Status: Closed (fixed) » Active

Reopening, will try to merge this into 8.x-3.x

swentel’s picture

Priority: Normal » Major
swentel’s picture

Title: Template suggestions does not work » Layout template suggestions does not work

Better title

swentel’s picture

Priority: Major » Normal
swentel’s picture

Title: Layout template suggestions does not work » Layout template suggestions does not always work

With the current code, it does seem to work, but I'm going to double check everything and change the default behavior or suggestions also to match core (with BC layer)

swentel’s picture

Issue tags: +Needs tests

Needs tests of course

  • swentel committed 833693cd on 8.x-3.x
    Issue #2887778 by swentel, MXT, gordon: Layout template suggestions does...
swentel’s picture

Status: Active » Fixed

committed and pushed, finally :)

swentel’s picture

Status: Fixed » Closed (fixed)
dpi’s picture

Created a issue which seems to be caused by the merge of this issue: #3415154: Missing template suggestions after upgrading to 3.17