简体   繁体   English

如何在magento的自定义模块中覆盖.phtml文件?

[英]How to override .phtml file in custom module of magento?

I want to override checkout/onpepage/payment.phtml in my custom module? 我想在自定义模块中覆盖checkout / onpepage / payment.phtml吗? In my module layout.xml i had used the code give below -: 在我的模块layout.xml中,我使用了以下代码:

<checkout_onepage_index>
      <reference name="payment">         
            <action method="setTemplate">
                <template>giftcard/checkout/onepage/payment.phtml</template>
           </action>      
     </reference>
 </checkout_onepage_index>

But payment.phtml file is not override in my custom module. 但是我的自定义模块中未覆盖payment.phtml文件。

I had gone through the below links and many more tutorials but not find the exact solution. 我浏览了以下链接和更多教程,但未找到确切的解决方案。

http://blog.chapagain.com.np/magento-overriding-template-file-from-custom-module/ http://www.magentocommerce.com/boards/viewthread/262202/#t352074 Magento Extension Needs to Override a Template http://blog.chapagain.com.np/magento-overriding-template-file-from-custom-module/ http://www.magentocommerce.com/boards/viewthread/262202/#t352074 Magento扩展程序需要覆盖模板

I had cleared the browser cache and magento cache. 我已经清除了浏览器缓存和magento缓存。

Customizing the core Magento 2 functionality is a bad coding practice. 自定义Magento 2的核心功能是不好的编码习惯。 The solution is to override a phtml file using a custom module in Magento 2. 解决方案是使用Magento 2中的自定义模块覆盖phtml文件。

Methods to Override a phtml file using a custom module in Magento 2: 在Magento 2中使用自定义模块覆盖phtml文件的方法:

  1. with plugin 带插件
  2. with XML 与XML

Learn the implementation of both the methods at https://meetanshi.com/blog/override-phtml-file-using-custom-module-in-magento-2/ https://meetanshi.com/blog/override-phtml-file-using-custom-module-in-magento-2/中了解这两种方法的实现。

Please also override it's .phtml file with the help of "block" tag in app/code/design/THEME/layout/checkout.xml. 也请借助app / code / design / THEME / layout / checkout.xml中的“ block”标记覆盖它的.phtml文件。 I have do this thing for one time. 我已经做过一次了。 it works for me. 这个对我有用。 i hope it will also work for u...... 我希望它也对你有用...

使用checkout.onepage.payment作为参考而不是付款,这将帮助您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM