I am trying to add a string at the top of the product details page navigation referenceContainer name="sidebar.main" but the string is coming after product Filters.

How can i change or move my block at the top of the filters section or sidebar main, as i have tried so many ways but no luck as i added below.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="sidebar.main">
          <block class="I95dev\Categorysearch\Block\Index\Index" name="index_index" template="index/index.phtml" before="-">

Can any one help me on this.

1 Answer 1


It's because the layered nav is also set to before="-", the fix is to move the layered nav so it displays after your new block.

<move element="catalog.leftnav" destination="sidebar.main" after="index_index" />

Old Answer

It's likely happening because the product filters also have before="-" set, so both are fighting to display first. I think setting your block to display before the product filters (name is catalog.leftnav) will fix it, like so:

<block class="I95dev\Categorysearch\Block\Index\Index" name="index_index" template="index/index.phtml" before="catalog.leftnav" />


<move element="catalog.leftnav" destination="sidebar.main" after="index_index" />

~~I'm not sure if this matters but I usually prefix the template with the module so the template would be:~~


  • I have tried this also, but not working Commented Jan 3, 2017 at 17:10
  • @krishnaijjadaati95Dev Hmmm possibly try it the other way round then, so move catalog.leftnav to be after your block? Off the top of my head it would be along the lines of <move element="catalog.leftnav" destination="sidebar.main" after="index_index" />
    – Ben Crook
    Commented Jan 3, 2017 at 17:13
  • Ok, I am posting the comment by my mobile, I will try and update you on my system. Thanks. Commented Jan 3, 2017 at 17:16
  • No problem, if it works I'll update my answer.
    – Ben Crook
    Commented Jan 3, 2017 at 17:51
  • @ Ben Crook, Move element is working as expected, layouts are always confusing. :) Thanks. Commented Jan 4, 2017 at 6:28

Your Answer

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

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