0

I have created one extension it is not working in my custom magento application(2.2.4) but it is working fine in default magento2.2.4.

I am getting error because of below code defaul.xml code:

<head>        
<block class="HK\Hplus\Block\CheckIframe" name="hplus_checkiframe" template="HK_Hplus::checkiframe.phtml"/>
</head>

============

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block': This element is not expected. Expected is one of ( title, css, link, meta, script, remove, attribute ). Line: 715

When i run my page it is throwing above error I have disabled all third party extension still getting this issue. Same extension working fine in native magento.

3
  • You cannot add block to your head block on this way. Commented Jul 9, 2018 at 12:04
  • @SukumarGorai it is working fine in default magento 2.2.4 so i don't think that is the reason.
    – user69071
    Commented Jul 9, 2018 at 12:06
  • In default magento did you use the same code on default.xml? Commented Jul 9, 2018 at 12:08

1 Answer 1

5

You cannot add block to your head block in this way. If you want to add then you can use the below code:

<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="HK\Hplus\Block\CheckIframe" name="hplus_checkiframe" template="HK_Hplus::checkiframe.phtml" />
        </referenceBlock>
    </body>
</page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.