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