0

How can we move current filter (Not whole layered navigation)?

enter image description here

  • Not whole layered navigation? – Amit Bera Sep 26 '18 at 10:47
0

Your question is about the "State" of the layered navigation. The layered navigation itself is the "FilterRenderer".

You'll find it in these 2 files:

  • vendor/magento/module-layered-navigation/view/frontend/layout/catalogsearch_result_index.xml
  • vendor/magento/module-layered-navigation/view/frontend/layout/catalog_category_view_type_layered.xml

You can add layout updates in your custom layout XML to remove the block and add it elsewhere.

<?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>
    <attribute name="class" value="page-with-filter"/>
    <referenceContainer name="sidebar.main">
        <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::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="Magento_LayeredNavigation::layer/filter.phtml"/>
        </block>
    </referenceContainer>
</body>

<block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state" as="state" />
0

So, you want to remove state section from filter then you have to move this block by below code

<referenceBlock name="catalog.navigation.state" remove="true">

That you have to create catalog_category_view_type_layered.xml & catalogsearch_result_index.xml at app/design/frontend/{ThemeVendor}/{Themename}/Magento_LayeredNavigation/layout and add below code both two files.

<?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="catalog.navigation.state" remove="true">
    </body>
</page>
0

I did it like this:

In my theme copy of: catalog_category_view_type_layered.xml

I copy the sidebar filters and use different names for them (you need them all for the filters to render), then I hide what I don't need with css

<?xml version="1.0"?>
<!--
/**
 * Copyright © 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">
            <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::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="Magento_LayeredNavigation::layer/filter.phtml"/>
            </block>
        </referenceContainer>

        <referenceContainer name="content">
            <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.custom.topnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
                <block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state.top" as="state" />
                <block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalog.navigation.renderer.top" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
            </block>
        </referenceContainer>
    </body>
</page>

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.