0

I have installed modules on Magento 2. I don't want to touch the module file. Is it possible to override that third-party module's template file from my Custom Module?

  • Yes you can in your desing folder can you post your code and name of your module – Mohamed El Mrabet Nov 27 '17 at 10:34
1

Use sequence in your module.xml in order to load phtml file from your custom module

app/code/Custom/Module/etc/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="Custom_Module" setup_version="1.0.0">
        <sequence>
            <module name="Thirdparty_Module"/>
        </sequence>
    </module>
</config>

app/code/Custom/Module/view/frontend/layout/thirdparty_module_action.xml

<referenceBlock name="third_party_block_name">
    <action method="setTemplate">
        <argument name="template" xsi:type="string">Custom_Module::thirdparty_template.phtml</argument>
    </action>
</referenceBlock>
0

You can override custom module's template by overriding it in your theme as follows :
Copy it in your theme under the path app/design/frontend/Anshu/mytheme/Custom_Mymodule/templates/<path_to_template_file>

Anshu : Your theme namespace
mytheme : Your theme name
Custom_Mymodule : Your module's name

and make required modifications.
I hope this will help you.

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.