簡體   English   中英

Magento覆蓋其他模塊中的模塊的塊

[英]Magento overwrite block from module in other module

嗨,我在Magento 1.7中擁有AffiliantePlus模塊。 我想覆蓋register.phtml塊。

在會員中加上/app/design/frontend/mytheme/default/layout/affiliateplus.xml關於注冊

<affiliateplus_account_register>
    <update handle="affiliateplus_default" />
    <reference name="content">
        <block type="affiliateplus/account_edit" name="affiliateplus_register" template="affiliateplus/account/register.phtml" />
    </reference>
</affiliateplus_account_register>

<affiliateplus_account_edit>
    <update handle="affiliateplus_default" />
    <reference name="content">
        <block type="affiliateplus/account_edit" name="affiliateplus_register" template="affiliateplus/account/edit.phtml" />
    </reference>
</affiliateplus_account_edit>

在/app/design/frontend/mytheme/defaule/layout/mymodule.xml中

<layout varsion="0.1.0">
<affiliateplus_account_register>
    <update handle="affiliateplus_default" />
    <reference name="content">
        <block type="affiliateplus/account_edit" name="affiliateplus_register" template="partner/account/register.phtml"/>
    </reference>
</affiliateplus_account_register>

我嘗試使用mymodule / account_edit,mymodule_register

塊被覆蓋,但是我的塊顯示了兩次。 這是有問題的,因為我無法更改原始塊。

您可以執行以下操作...擺脫原始塊,並使用另一個名稱添加新塊,因為它顯然是自渲染內容塊。

<affiliateplus_account_register>
 <reference name="content">
    <action method="unsetChild"><name>affiliateplus_register</name></action>
 </reference>
</affiliateplus_account_register>

但是,因為您只是使用另一個模板,所以我建議您而不是您的xml來簡單地更改模板並保留其他所有內容

 <affiliateplus_account_register>   
   <reference name="affiliateplus_register">
     <action method="setTemplate">
       <template>partner/account/register.phtml</template>
     </action>   
  </reference> 
 </affiliateplus_account_register>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM