3

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

3
  • add this block in your default.xml <referenceBlock name="sidebar.main" remove="true"/>
    – Yogesh
    Sep 26, 2017 at 13:14
  • I only want to remove the sidebar on the search results page, won't that hide the sidebar throughout my site if I add it to default.xml?
    – lky
    Sep 26, 2017 at 13:22
  • Please add on your theme Magneto_Search/view/frontend/layout
    – Yogesh
    Sep 26, 2017 at 13:23

1 Answer 1

2

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

Your Answer

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

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