简体   繁体   English

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

[英]How to override media.phtml in my custom magento module?

I am working on a custom module which takes product images from external server. 我正在使用一个自定义模块,该模块从外部服务器获取产品图像。 I have overridden a few functions to get the required result. 我重写了一些函数来获得所需的结果。

But I have to override base/default/template/catalog/product/view/media.phtml inside my custom module. 但是我必须在自定义模块中覆盖base/default/template/catalog/product/view/media.phtml

I tried to do this from default/layout/MY_MODULE.xml but that did not work for me. 我尝试从default/layout/MY_MODULE.xml执行此操作,但是这对我不起作用。

How do I override the media.phtml inside default/MY_MODULE . 如何重写media.phtmldefault/MY_MODULE

I think calling setTemplate method is not the right way to override template file in your case. 我认为调用setTemplate方法不是在您的情况下覆盖模板文件的正确方法。 For me it looks a bit redundant and unclear: you are assigning template to block and the immediately reassign it with action. 对我来说,它看起来有些多余且不清楚:您正在分配要阻止的模板,并立即通过操作对其进行重新分配。 I would do this way: 我会这样:

<catalog_product_view> 
    <reference name="product.info"> 
        <block type="catalog/product_view_media" name="product.info.media" as="media" template="MY-MODULE/catalog/product/view/media.phtml" />
    </reference>
</catalog_product_view>

I think you could also reference to product.info.media directly and call setTemplate action there 我认为您也可以直接引用product.info.media并在其中调用setTemplate操作

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

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