Magento 2.1.7 – How to Add a Div in Main Tag with Custom PHTML Template

layoutlayout-updatemagento-2.1.7page-layouts

I would like to add a div inside <main id="maincontent" class="page-main"> from my custom module please look at screen shoot:

enter image description here

Can you see a class="MYCUSTOMBLOCKHERE" in the image I need to add this div.

Any help I Appreciate. Thanks

Best Answer

<referenceContainer name="columns.top">
    <container name="custom.view.container" htmlTag="div" htmlClass="custom-view" before="page.messages">
        <block class="company\module\Block\entity" name="customView" template="company_module::custom.phtml" />
    </container>
</referenceContainer>

Flush cache and clear cache and check it.

you can find all block name into

vendor\magento\module-theme\view\frontend\layout\default.xml

Related Topic