0

I am trying to override phtml file inside theme module. Below is my code

Module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Netsmartz_Welcomemessage" setup_version="1.0.1">
    <sequence>
        <module name="Magento_Theme"/>
    </sequence>
</module>
</config>

Default.xml

<?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="messages">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Magento_Theme::messages.phtml</argument>
        </action>
    </referenceBlock>
</body>
</page>

I have placed messages.phtml file in app\code\Netsmartz\Welcomemessage\view\frontend\templates\theme path.

Any idea what could be wrong.

2 Answers 2

2

In argument (default.xml) you have specify your new phtml file. But you have given original phtml file. Instead of Magento_Theme you have to use Netsmartz_Welcomemessage::theme/messages.phtml

<referenceBlock name="messages">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Netsmartz_Welcomemessage::theme/messages.phtml</argument>
        </action>
    </referenceBlock>
0

You have to change the template file path in the default.xml file like

<?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="messages">
        <action method="setTemplate">
            <argument name="template" xsi:type="string">Netsmartz_Welcomemessage::messages.phtml</argument>
        </action>
    </referenceBlock>
</body>
</page>

Your Answer

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

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