Problem/Motivation
Layout template refer to civictheme component namespace causing error when another theme renders a node.
CivicTheme layouts (in civictheme.layouts.yml) define a template for the layout. These templates refer to a child template with:
include '@base/layout/content-layout--single-column.twig
Base namespace is a CivicTheme component namespace so when another theme renders a nodeusing a CivicTheme layout they cannot locate this component because it is a CivicTheme namespace and component.
Twig\Error\LoaderError: Template "@base/layout/content-layout--single-column.twig" is not defined in "themes/contrib/civictheme/templates/layout/layout--single-column.html.twig" at line 19
Steps to reproduce
1. Create a view
2. Create a page display with the settings content of `full posts`
2. Update the display format to show "Full Content" ie the rendered view of the node
3. Generate preview for the view
3. Open the developer console you should see a 500 ajax error with the above error
Proposed resolution
Update the layout templates to have inlined content layout templates. This way we provide the active theme all the required template to render the layout for the node.
Issue fork civictheme-3441713
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3441713-layout-error-when
changes, plain diff MR !7
Comments
Comment #3
alex.skrypnykWe looked deeper into the issue and it appears that the CivicTheme incorrectly uses layout functionality.
The layout template is expected to be available site-wide and, therefore, not supposed to contain any other template inclusions. For styling, the layout could reference a library (which in own turn can use CSS to style that layout). The expectation is that every theme is responsible for providing styles to support layouts.
At his point, it looks like we definitely need to simplify the layout template to not include any other components. We also need to look into shipping a standalone layout CSS file.
We also need to assess if it is worth ditching our custom layout in favour of the Drupal core's layouts markup and just add our own CSS (need to assess if that CSS is already provided by core).
Once the above investigations conducted, the results will be posted into this issue.
Comment #4
jdleonardI ran into this as well while simply viewing a page node. It might have been using a sub-theme, but I hadn't made any changes to the sub-theme.
Comment #5
fionamorrison23 commentedComment #6
jdleonardCopying the files changed by https://git.drupalcode.org/project/civictheme/-/merge_requests/7/diffs?c... into my sub-theme resolved the error for me.
Comment #9
alex.skrypnykFixed and will be released in 1.8
Comment #11
fionamorrison23 commented