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

5

Use

<referenceBlock name="head.additional">

Instead of

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

-1

Update your code with head.additional

<referenceBlock name="head.additional"> <block class="Magento\Framework\View\Element\Js\Components" name="frontuser" as="frontuser" template="Frontuser_Tags::frontuser/tags.phtml"/> </referenceBlock>

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.