0

I am trying to overwrite this template from a custom module but nothing at all is working. I've tried arguments to set the template... I've messed with sequence.

Below is the code in Vendor/Module/view/frontend/layout/catalog_category_view.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="catalog_category_view"/>

    <body>
        <referenceBlock name="category.products">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Elcometer_Quote::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

This will not work, it is placed: app/code/Vendor/Module/view/frontend/layout

What am I doing wrong?

2

We need to declare nodes: <action method="setTemplate"> and <update handle="catalog_category_view"/> in your layout.

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <update handle="catalog_category_view"/>
    <body>
        <referenceBlock name="category.products">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Elcometer_Quote::product/list.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>
| improve this answer | |
  • 1
    Why touch catalog_product_view? I'm trying to modify the category view. – LM_Fielding Aug 22 '16 at 13:48
  • 1
    Yes, try with <update handle="catalog_category_view"/>. – Khoa TruongDinh Aug 22 '16 at 13:51
  • So I'm using update handle catalog_category_view in my module/catalog_category_view.xml layout file? Could you explain the logic behind that? – LM_Fielding Aug 22 '16 at 13:52
  • Updated, nothing happened. – LM_Fielding Aug 22 '16 at 13:59
1

You need the <action method="setTemplate"> tag:

<referenceBlock name="search_result_list">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Elcometer_Quote::html/topmenu.phtml</argument>
        </action>
    </referenceBlock>
| improve this answer | |
  • Testing now.... – LM_Fielding Aug 22 '16 at 13:35
  • That didn't work, I cleared cache too. I am getting some merged layout INFO errors. – LM_Fielding Aug 22 '16 at 13:36
  • Updated with my layout code. – LM_Fielding Aug 22 '16 at 13:38
  • 1
    Yes, the only part that should change is the template file being referenced. I tested that code and it should work. – Aaron Allen Aug 22 '16 at 14:07
  • 1
    No, that was specific to your other question. – Aaron Allen Aug 22 '16 at 14:19
0

The problem was trying to target catalog_category_view, the page I was attempting to manipulate the product list block could only be modified by catalog_category_view_type_layered.xml.

If anyone could further explain this, I would greatly appreciate it.

Additionally, I now have a problem where a method that the template wants to use isn't available on that template.

| improve this answer | |
  • So did you find a solution? For your other concern, please open a new question. – Julien Lachal Aug 22 '16 at 15:51
  • Yes, I did I will make it bold. Thanks for the comment. – LM_Fielding Aug 22 '16 at 15:52
0

Hi you trying to change template of the "category.products" instead of "category.products.list". Your code should be like this:

    <referenceBlock name="category.products.list">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Elcometer_Quote::product/list.phtml</argument>
        </action>
    </referenceBlock>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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