2

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="-">
            </block>
        </referenceContainer>
</page>

Can any one help me on this.

1 Answer 1

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" />

~~Or~~

<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:~~

template="I95dev/Categorysearch::index/index.phtml"

5
  • I have tried this also, but not working 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
    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. Jan 3, 2017 at 17:16
  • No problem, if it works I'll update my answer.
    – Ben Crook
    Jan 3, 2017 at 17:51
  • @ Ben Crook, Move element is working as expected, layouts are always confusing. :) Thanks. Jan 4, 2017 at 6:28

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.