0

I want display a phtml file in the header, i created a phtml file and called in the default.xml but it is giving invalid template file block's name, what should be give as a block name

menubtn.phtml

<div class="headercustomlink">MENU</div>

default.xml

<referenceBlock name="header.container">
        <block class="Magento\Framework\View\Element\Template" name="custom_menu" after="-" template="Company_module::menubtn.phtml"/>
    </referenceBlock>
0

The error means Magento can't find your phtml file.

template="Company_module::menubtn.phtml"

your phtml file should be in either following location:

app/code/Company/module/view/frontend/templates/menubtn.phtml

or

app/design/Company/module/view/frontend/templates/menubtn.phtml

Though, I assume your module is actually named "Module" and not "module", so if it is in the right location, verify that is indeed the correct folder name/module name in your layout file. It is case sensitive.

The name of the block can be anything, as long as it doesn't conflict with another block's name.

0

i am trying to access the template from the theme itself that's why i am getting error, now i created a module and added phtml file in template folder. now its coming good.

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.