0

I'm using Magento 2 with Luma theme, and I'm trying to add a block on the home page only, right under the main navigation, and I want to do it without any margin or padding, full width, basically not in a wrapper. The problem is that if I create the block and then add it into a widget, the widget css class has a max-width and some padding, and I don't want to force that css class. There is a proper way to add that block to the page, not wrapped in that widget class?

2 Answers 2

1

Create new cms_index_index.xml in your theme

/app/design/frontend/Vendor/YourTheme/Magento_Cms/layout/cms_index_index.xml

Add below code in xml file :

<?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="page.top">
        <block class="Magento\Cms\Block\Block" name="test_cmsblock" after='catalog.topnav'>
            <arguments>
                <argument name="block_id" xsi:type="string">test_cmsblock</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>
</page>
2
  • Is that working for you ? May 30, 2018 at 6:34
  • Is above solution works for you please vote and accept so another person use same :) May 31, 2018 at 10:31
0

Try this in your theme default.xml file -

<referenceBlock name="page.top">
            <block class="Magento\Cms\Block\Block" name="block_identifier" after='catalog.topnav'>
                <arguments>
                    <argument name="block_id" xsi:type="string">below-navigation-block</argument>
                </arguments>
            </block>    
        </referenceBlock>

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.