I am trying to override layered navigation template in a Magento2 app. Here is my code:

Layout configuration:

<!-- app/code/MyVendor/MyModule/view/frontend/layout/default.xml -->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="catalog.leftnav">
            <argument name="template" xsi:type="string">MyVendor_MyModule::view.phtml</argument>
    <referenceBlock name="catalogsearch.leftnav">
            <argument name="template" xsi:type="string">MyVendor_MyModule::view.phtml</argument>

Module configuration:

<!-- // app/code/MyVendor/MyModule/etc/module.xml -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/Module/etc/module.xsd">
<module name="MyVendor_MyModule" setup_version="2.0.0">
        <module name="Magento_Catalog"/>
        <module name="Magento_CatalogSearch"/>
        <module name="Magento_Swatches"/>
        <module name="Magento_ConfigurableProduct"/>
        <module name="Magento_Eav"/>
        <module name="Magento_Customer"/>
        <module name="Magento_Store"/>
        <module name="Magento_Backend"/>
        <module name="Magento_MediaStorage"/>
        <module name="Magento_Config"/>
        <module name="Magento_LayeredNavigation"/>
        <module name="Magento_Theme"/>

Template file:

// app/code/MyVendor/MyModule/view/frontend/templates/view.phtml
Some template code here

I have cleared the cache (including "generation" folder) and recompiled dependencies, still Magento loads the template from LayeredNavigation module. How do I make it render my custom template instead?

I was able to override it in my custom theme: app/design/frontend/MyVendor/MyTheme/Magento_LayeredNavigation/templates/layer/view.phtml

So now the question is, how to make a template in custom module override one set by a custom theme?

  • Did you try put your view.phtml template inside /layer folder?
    – Sushivam
    Commented Jul 13, 2016 at 7:33
  • I did not, but I believe that's not necessary as long as path to template is correctly specified. Anyways, @aaron-allen has answered my question below, it all works now.
    – Vasily802
    Commented Jul 13, 2016 at 7:36
  • Yes , but im trying to do the same override for Catalogsearch, with my custom phtml file, i get blank page..
    – Sushivam
    Commented Jul 13, 2016 at 7:41
  • Well, best bet would be to post your code in a new question.
    – Vasily802
    Commented Jul 13, 2016 at 7:44
  • magento.stackexchange.com/questions/122625/… have updated my code here for the same scenario
    – Sushivam
    Commented Jul 13, 2016 at 7:52

1 Answer 1


Your xml tags should look like this:

<referenceBlock name="block.name">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">MyVendor_MyModule::view.phtml</argument>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.