質問

I'm using magento 2 , and I would need to add some content before the body closing tag , on every page. What's the most correct way to do that ?

役に立ちましたか?

解決

You can use before.body.end as the reference name and add the block using layout/default xml

Here is an example: Magento 2 add script before closing body tag

Look at KAndy's answer.

他のヒント

you can simply add block with xml add this in default.xml

<referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template" name="beforebody"  template="Magento_Theme::beforebody.phtml"/>
</referenceContainer>

reference

One possibility is via the Magento Admin:

Admin -> Stores -> Configuration -> Design -> Footer -> Miscellaneous HTML

Another option via the Magento Admin is to use a widget to include a static block:

Admin -> Content -> Widget: CMS Static Block
  Layout Updates: 
     Display on: All Pages
     Container: Page Bottom

If creating/customizing a theme then you could consider using layout XML to include a template or static block.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top