Magento 2 - How to remove catalog.leftnav only from category pages with 2columns-right.xml

2018-02-22 07:07:38

I have created a Magento 2 module which has some customization for the category pages.

I would like to remove catalog.leftnav when the category is using the "2 columns with right bar" layout. Is there anyway I can do this in my modules Layout files?

So far I've tried adding to /view/frontend/page_layout/2columns-right.xml but this did nothing.

Then I tried adding to /view/frontend/layout/catalog_category_view.xml but this removed it from everywhere, even pages with 3 column layout.

UPDATE

After reading through the docs on this, I have now also tried creating the following file

app/design/frontend/Holy/mytheme/Magento_LayeredNavigation/page_layout/2columns-right.xml

  • catalog.leftnav is a container so you need to use:

    When you are choosing the layout for the category, you can also remove the leftnav by updating the Layout Update XML settings for the category with this. It is right below the page layout option.

    2018-02-22 09:07:04