Magento覆盖其他模块中模块的块

时间:2013-09-02 08:56:05

标签: php magento magento-1.7

您好,我在Magento 1.7中有AffiliantePlus模块。 我想覆盖register.phtml块。

在affiliate plus /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

Block被覆盖但我的块被显示两次。这是问题,因为我不能改变oryginal块。

1 个答案:

答案 0 :(得分:2)

你可以做这样的事情......摆脱原始的块并添加另一个名称,因为它显然是一个自我渲染的内容块。

<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>
相关问题