In magento1 we use this reference to add block after body tag.
<reference name="after_body_start">
</reference>
same also use in magento 1
<reference name="before_body_end"></reference>
what is replacement of this code in magento 2?
You can check inside page_layout/empty.xml
file inside module-theme/base
folder.
<container name="after.body.start" as="after.body.start" before="-" label="Page Top"/>
<container name="before.body.end" as="before_body_end" after="-" label="Page Bottom"/>
You can check reference from vendor/magento/module-catalog/view/frontend/layout/default.xml
here also:
<referenceContainer name="after.body.start">
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Catalog::js/components.phtml"/>
</referenceContainer>
So in Magento 2 , you can use referenceContainer
node to define same as in Magento 1.
Thanks.
Refer working example, you can place it default.xml
or specific layout file in your module.
<referenceContainer name="content">
<block class="Vendorname\Modulename\Block\Manufacturer\Grid" name="manufacturer_grid" template="templates\test.phtml" before="before.body.end">
</block>
</referenceContainer>
If you want to add before or after you can create reference container as posted.
before= "before.body.end"
after = "before.body.end"
Here is an excellent answer from Raphael
Hope this helps ....:)
name="before_body_end"
anymore in Magento 2. check the file \vendor\magento\module-theme\view\adminhtml\page_layout\admin-1column.xml
it is name="before.body.end" as="before_body_end"
the name is used as an alias. we have to use reference container name as i mentioned to add phtml.
Commented
May 27, 2016 at 9:53