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?

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

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>
  • Is that working for you ? – hweb87 May 30 '18 at 6:34
  • Is above solution works for you please vote and accept so another person use same :) – hweb87 May 31 '18 at 10:31

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.