Skip to main content
added 21 characters in body
Source Link
Piyush
  • 5.9k
  • 9
  • 34
  • 66

You are wrong in the aspect of how templates in modules works. You are trying to override template of module A in B by creating it in module's B view/../.. path. It will not work.

If you want to override phtml template from a module you must do at least two things:

  1. Create desired template in module as you actually did.

  2. In layout xml file inside of your module set your template for a given block with some variation of the following snippet:

    <referenceBlock name="REF_BLOCK"> <action method="setTemplate"> <argument name="template" xsi:type="string">Vendor_Module::path/to/template/file.phtml</argument> </action> </referenceBlock>

    <referenceBlock name="REF_BLOCK">
        <action method="setTemplate">
           <argument name="template" xsi:type="string">Vendor_Module::path/to/template/file.phtml</argument>
        </action>
    </referenceBlock>
    

Simple putting template in custom module along with setting sequence is not enough. That approach is only for custom designs where you can actually put your template in appropriate path in custom design package and it will override original template automatically if custom design is enabled. But that is not a case with custom modules.

You are wrong in the aspect of how templates in modules works. You are trying to override template of module A in B by creating it in module's B view/../.. path. It will not work.

If you want to override phtml template from a module you must do at least two things:

  1. Create desired template in module as you actually did.

  2. In layout xml file inside of your module set your template for a given block with some variation of the following snippet:

    <referenceBlock name="REF_BLOCK"> <action method="setTemplate"> <argument name="template" xsi:type="string">Vendor_Module::path/to/template/file.phtml</argument> </action> </referenceBlock>

Simple putting template in custom module along with setting sequence is not enough. That approach is only for custom designs where you can actually put your template in appropriate path in custom design package and it will override original template automatically if custom design is enabled. But that is not a case with custom modules.

You are wrong in the aspect of how templates in modules works. You are trying to override template of module A in B by creating it in module's B view/../.. path. It will not work.

If you want to override phtml template from a module you must do at least two things:

  1. Create desired template in module as you actually did.

  2. In layout xml file inside of your module set your template for a given block with some variation of the following snippet:

    <referenceBlock name="REF_BLOCK">
        <action method="setTemplate">
           <argument name="template" xsi:type="string">Vendor_Module::path/to/template/file.phtml</argument>
        </action>
    </referenceBlock>
    

Simple putting template in custom module along with setting sequence is not enough. That approach is only for custom designs where you can actually put your template in appropriate path in custom design package and it will override original template automatically if custom design is enabled. But that is not a case with custom modules.

Source Link

You are wrong in the aspect of how templates in modules works. You are trying to override template of module A in B by creating it in module's B view/../.. path. It will not work.

If you want to override phtml template from a module you must do at least two things:

  1. Create desired template in module as you actually did.

  2. In layout xml file inside of your module set your template for a given block with some variation of the following snippet:

    <referenceBlock name="REF_BLOCK"> <action method="setTemplate"> <argument name="template" xsi:type="string">Vendor_Module::path/to/template/file.phtml</argument> </action> </referenceBlock>

Simple putting template in custom module along with setting sequence is not enough. That approach is only for custom designs where you can actually put your template in appropriate path in custom design package and it will override original template automatically if custom design is enabled. But that is not a case with custom modules.