7

I want to add block in tag. I dont want to add this script in Configuration > HTML Head > Scripts and Style Sheets. Please check attached screenshot.

<?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>
        <referenceContainer name="after.body.start">
            <block class="Magento\Framework\View\Element\Js\Components" name="frontuser" as="frontuser" template="Frontuser_Tags::frontuser/tags.phtml"/>
        </referenceContainer>
    </body>
</page>

enter image description here

22

Replace this following code in your Layout Xml. This will work for you.

<?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="head.additional">
            <block class="Magento\Framework\View\Element\Template" name="frontuser" template="Frontuser_Tags::frontuser/tags.phtml"/>
        </referenceBlock>
    </body>
</page>

Hope this helps you

  • not working for me in m2.3.2 – Anas Mansuri Aug 20 at 6:47
  • <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="head.additional"> <block class="Magento\Framework\View\Element\Template" name="help" template="Sample_Help::help.phtml"/> </referenceBlock> </body> </page> – Anas Mansuri Aug 20 at 6:49
5

Use

<referenceBlock name="head.additional">

Instead of

<referenceContainer name="after.body.start">

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.