簡體   English   中英

如何在自定義模塊中覆蓋radio.phtml?

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

我創建了一個自定義模塊,該模塊更改了bundle產品選項的模板,它位於radio.phtml

我現在重寫radio.phtml上一個新的主題xxx/template/bundle/catalog/product/view/type/bundle/option/radio.phtml

但是我想把radio.pthml放到我的自定義模塊文件夾中,即template/mycompany/mymodule/radio.phtml

我了解可以通過使用<action method="setTemplate">mymodule.xml布局中進行<action method="setTemplate"> ,但是如何知道radio.phtml<reference>名稱?

您需要重寫此塊,因為主題是在塊中設置的。

Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio

你可以在這個功能

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

你可以像這樣重寫模塊

<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>

並調用您的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