Skip to content

Invalid Template with Custom Theme Applied by User Agent #14932

@C0D31GN1T3R

Description

@C0D31GN1T3R

Preconditions

Magento 2.2.2

Steps to reproduce

  1. Register a new theme with no parent.
  2. Create Magento_Theme dir and either add a new block in footer container with a template that doesn't exist in the core files, or edit the template of an existing block giving it a new template that doesn't exist in the core files.

For example:

<referenceContainer name="footer">
    <block class="Magento\Framework\View\Element\Template" name="some.block" template="Magento_Theme::some-template-that-exists-in-my-custom-theme-but-not-in-core.phtml" />
</referenceContainer>
  1. In chrome for example under network change user agent to whatever is required to enable the theme and visit any product view page.

Expected result

  1. When user agent matches what is required to enable custom theme, everything works as normal but with custom theme applied.

Actual result

  1. Invalid Template Error is produced relating to the block which uses a template that is not available in the core files.

For some reason when a theme is a applied based on user agent, it is not applied to certain sections. The footer is one, another is when trying to override review.phtml from Magento_Reviews dir. In the case of the footer because I was using templates that didn't exist in the base module I get the invalid template error because Magento is not applying my theme but looking for my templates in the base module. In the case of Magento_Reviews reviews.phtml there are no errors as the file exists in the base module but the override has no effect as my theme is not applied.

This seems to be selective as custom templates in the header section work fine on the product view page. I've only noticed the footer and reviews.phtml issue but there could be others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions