Magento – How to remove the sidebar.main block from the search results page

catalogsearchlayered-navigationmagento2xml

I am trying to remove the sidebar.main block from my search results page as I do not require the layered navigation on this page.

I have copied the following XML:

\vendor\magento\module-layered-navigation\view\frontend\layout\catalog_category_view_type_layered.xml

To:

app\design\frontend\theme\theme\Magento_LayeredNavigation\ layout\catalog_category_view_type_layered.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <attribute name="class" value="page-with-filter"/>
        <referenceContainer name="sidebar.main" remove="true">
            <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="layer/view.phtml">
                <block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state" as="state" />
                <block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalog.navigation.renderer" as="renderer" template="layer/filter.phtml"/>
            </block>
        </referenceContainer>
        <referenceBlock name="sidebar.main" remove="true"/>
    </body>
</page>

How can I remove this as I am having no luck? Is there a different XML I need to edit in order to remove this?

Thanks

Best Answer

I have resolved this :)

I added the following:

<referenceBlock name="sidebar.main" remove="true"/>

To the following XML file within my theme and it removed the sidebar.

Magento_CatalogSearch > layout > catalogsearch_result_index.xml

Related Topic