0

I'm using Magestores Bannerslider with custom templates in order to create Sliders.

I want to place the slider above page.main and below the nav.section element.

This is my code in cms_index_index.xml:

<?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>

        <referenceContainer name="page.wrapper" before="page.main">
            <block class="Magestore\Bannerslider\Block\SliderItem" name="slider">
                <action method="setSliderId">
                    <argument name="sliderId" xsi:type="string">1</argument>
                </action>
            </block>
        </referenceContainer>

    </body>

</page>

However, the element appears after page.main. From my understanding, placing it before that element should be enough, but it does not work. Why?

1

Try following way:

<?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>
        <referenceContainer name="page.wrapper">
            <block class="Magestore\Bannerslider\Block\SliderItem" name="slider" before="page.main">
                <action method="setSliderId">
                    <argument name="sliderId" xsi:type="string">1</argument>
                </action>
            </block>
        </referenceContainer>
    </body>
</page>
5
  • Didn't you mean "use block instead of referenceContainer"? Where exactly have I used a htmlClass? Just curious, want to understand exactly what I have done wrong.
    – Max
    Feb 2 '17 at 20:09
  • "page-main" is not container name, It's html class name.
    – Sohel Rana
    Feb 2 '17 at 20:11
  • Thats what I expected, but I didn't used page-main, but page.main. But then it's clear what you've meant.
    – Max
    Feb 2 '17 at 20:15
  • 1
    Uhh! yes right. Check updated answer.
    – Sohel Rana
    Feb 2 '17 at 20:16

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.