简体   繁体   中英

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 .

I am now overriding the radio.phtml on a new theme 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

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 ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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