简体   繁体   中英

Magento overwrite block from module in other module

Hi I have AffiliantePlus Module in Magento 1.7. I want overwrite register.phtml block.

In affiliate plus /app/design/frontend/mytheme/default/layout/affiliateplus.xml about register

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

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

I tryed with mymodule/account_edit, mymodule_register

Block is overwrited but my block is show twice. It's problem because I can't change oryginal block.

You could do something like this...to get rid of the original block and add the new one with another name, since its obviously a self rendering content block.

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

But as you are just using another template i would advise you instead of your xml to simply change the template and keep everything else like it was

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

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