简体   繁体   English

如何在自定义模块中覆盖radio.phtml?

[英]How to override the radio.phtml in custom module?

I have created a custom module which change the template for the bundle product option, it is in the radio.phtml . 我创建了一个自定义模块,该模块更改了bundle产品选项的模板,它位于radio.phtml

I am now overriding the radio.phtml on a new theme xxx/template/bundle/catalog/product/view/type/bundle/option/radio.phtml . 我现在重写radio.phtml上一个新的主题xxx/template/bundle/catalog/product/view/type/bundle/option/radio.phtml

But I want to put the radio.pthml into my custom module folder, that is template/mycompany/mymodule/radio.phtml 但是我想把radio.pthml放到我的自定义模块文件夹中,即template/mycompany/mymodule/radio.phtml

I understand that I can do in the mymodule.xml layout by using <action method="setTemplate"> , but how can I know the <reference> name for the radio.phtml ? 我了解可以通过使用<action method="setTemplate">mymodule.xml布局中进行<action method="setTemplate"> ,但是如何知道radio.phtml<reference>名称?

you need to rewrite this block because the theme are set in block.. 您需要重写此块,因为主题是在块中设置的。

Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio

you can in this function 你可以在这个功能

protected function _construct()
    {
        $this->setTemplate('bundle/catalog/product/view/type/bundle/option/radio.phtml');
    }

you can rewrite block module like that 你可以像这样重写模块

<global>
        <blocks>
            <bundle>
                <rewrite>
                    <catalog_product_view_type_bundle_option_radio>Spacename_Modulname_Block_Adminhtml_Radio</catalog_product_view_type_bundle_option_radio>
                </rewrite>
            </bumdle>
        </blocks>
    </global>

and call your phtml file 并调用您的phtml文件

class Spacename_Modulname_Block_Adminhtml_Radio extends Mage_Core_Block_Template
{
  protected function _construct()
        {
            $this->setTemplate('test/radio.phtml'); //your file path link here
        }
}

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

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