When we are using the last version drupal (8.3.1) and using layout discovery instead layout plugin we have some problems to find the template twig file. Was reported on:
https://www.drupal.org/node/2862683#comment-12047721 and https://www.drupal.org/node/2867794. With my patch we fix this problem.

Members fund testing for the Drupal project. Drupal Association Learn more


fastangel created an issue. See original summary.

fastangel’s picture

Status: Active » Needs review
markcarver’s picture

Priority: Critical » Normal
Status: Needs review » Closed (won't fix)

Core supplies this property automatically, that's why this patch is adding a line, not changing an existing line; which would then mean it's a bug with this project.

fastangel’s picture

@markcarver I think is a bug on Bootstrap. If you try this:
* enable drupal 8.3.1
* Enable display suite 8.x-3.0-beta3
* Enable boostrap theme

If you create a new display mode for a users and use a twocol layout for example you get this error if you try override the twocol layout on the theme. The path, .... everything is ok but the template is incorrect. If you use another theme (seven, ....) work fine (This can be related with the problem on core to find templates). I think we can add this change while is fixed. In another theme work fine because always use the template on module instead to find the override on theme.

NOTE: Bug on core I was talking https://www.drupal.org/node/2862683

markcarver’s picture

54.98 KB

I don't know what to tell you other than it's not an issue with this base theme. I can override in a sub-theme just fine:

fastangel’s picture

Are you sure?. I'm using a subtheme and I have the problem. With:
* drupal 8.3.1
* display suite 8.x-3.0-beta3
* layout discovery module (core)

We can't override a template and you get a exception with boostrap/subtheme theme only.

markcarver’s picture

Are you sure?

Yes, I'm sure. I just posted the screenshot didn't I?

I tested this with the latest git commits in all projects (core-8.3.x, ds-8.x-3.x, bootstrap_layouts-8.x-5.x).

sedax’s picture

The problem is not with base templates as I explained before, but with overridden templates with a suggesion name es. bs-1col--node-theater-menu.html.twig

markcarver’s picture

Version: 8.x-4.x-dev » 8.x-3.x-dev
Priority: Normal » Critical
Status: Closed (won't fix) » Fixed
1.69 KB

@fastangel, I must apologize. You were correct.

I just stepped through all of this, in great length, to determine where the break down is happening.

The problem technically is a result of core's \Drupal\Core\Theme\Registry::mergePreprocessFunctions when it merges the "parent hook" with the existing cache:

$cache[$destination_hook_name] = $parent_hook + $cache[$source_hook_name];

However, since this base theme does all this in an alter hook to "Ensure paths to templates are set properly.", it creates a "fake" hook so they can get processed by core later.

Because the base hooks already have their templates, these get populated to the suggestions as well, thus not getting properly later.


I'm committing your patch above, but with a small tweak so it only sets the template when it creates a new theme hook for the suggestion.

It also includes making some minor documentation and whitespace changes to help explain this a bit better.

  • markcarver committed ff2d0bb on 8.x-3.x authored by fastangel
    Issue #2871551 by fastangel, markcarver: Problem to find template file
markcarver’s picture

@sedax, this should solve your problems.

fastangel’s picture

Perfect. I was creating a environment on pantheon to show you hehe.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.