1

I want to remove the category image and title at the top of the default category product listing page. I have followed the DevDocs page on overriding an XML layout file:

http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/xml-instructions.html

And after flushing the cache, removing generated files from the VAR folder, and rebuilding those, the supposedly modified layout remains unchanged.

I have found conflicting advice online regarding the naming of override files, and have tried them both without success. One says it should be called default.xml while the other says use the same name as the xml file being overridden (this one makes more sense to me).

Is there a step I'm missing in getting the modification to work? Are the steps outlined in the docs wrong?

I have copied this file: vendor\magento\module-catalog\view\frontend\layout\catalog_category_view.xml

To: app\design\frontend\vendor\theme\Magento_Catalog\layout\catalog_category_view.xml

And added the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
        <referenceBlock name="columns.top" remove="true"/>
    </body>
</page>

I have also tried removing just one of the named blocks to see if the override is working and I am unable to remove the entire container, but no!??

<referenceBlock name="category.image" remove="true"/>

Could someone please tell me what I am doing wrong, or missing?

0

Add below code to

app\design\frontend\vendor\theme\Magento_Catalog\layout\catalog_category_view.xml

    <?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="category.image" remove="true" />
        <referenceBlock name="page.main.title" remove="true" />
    </body>
</page>
| improve this answer | |
  • Hi, I have already tried one of your two lines, but the items are not removed from the page, so adding another block to remove won't work. Something else is either wrong, or I am missing a step in forcing magento to use the overridden files? – robgt May 11 '17 at 13:06
  • Your layout is 2-column left ? – Suresh Chikani May 11 '17 at 13:07
  • It is 2-column left, yes. – robgt May 11 '17 at 13:08
  • You are missing layout="2columns-left" in your xml file. See my update answer and try. – Suresh Chikani May 11 '17 at 13:09
  • Still no joy. Am I missing something in clearing out Magento to make the new code apply? I clear cache, I remove generated files and then I recreate generated files??? – robgt May 11 '17 at 13:23
0

I was missing the fact that my custom theme needed to be registered in the system. There were a number of confusing factors here for me, so I will be brief in summing them up, in case it helps someone else who may have stumbled where I did.

I am using a purchased theme as my starting point for my store. In order for me to change things in that theme, I had to:

  1. Create a custom child theme, inheriting from the purchased theme. My custom child theme requires a registration.php file and theme.xml file, per the documentation.

  2. Apply my custom child theme in Magento admin as the theme being used on the site. (This step was where the confusion really came in!).

Once that was done, everything fell into place (after the usual bin/magento commands to clear everything up!!).

I hope this helps someone else tripped up by the ever so slightly lacking info out there.

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