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

Command icon 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:

Comments

RichardGaunt created an issue. See original summary.

alex.skrypnyk’s picture

We 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.

jdleonard’s picture

I 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.

fionamorrison23’s picture

Assigned: Unassigned » alex.skrypnyk
Issue tags: -layouts, -Layout Builder, -Twigtemplate, -components +release1.8
jdleonard’s picture

Copying the files changed by https://git.drupalcode.org/project/civictheme/-/merge_requests/7/diffs?c... into my sub-theme resolved the error for me.

  • c2f1be52 committed on 1.x
    Issue #3441713 by RichardGaunt: Layout error when another theme renders...

alex.skrypnyk’s picture

Status: Active » Fixed
Issue tags: -release1.8 +civictheme-release-1.8

Fixed and will be released in 1.8

Status: Fixed » Closed (fixed)

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

fionamorrison23’s picture