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
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 above solution works for you please vote and accept so another person use same :) May 31, 2018 at 10:31
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>