dhardy
dhardy

Reputation: 1003

Magento override nested block

I have my local.xml set up as follows:

<cms_index_index translate="label">
    <reference name="content">
        <block name="promos" type="page/html" template="cms/promos/homepage.phtml" as="promos" />
        <block type="page/html_wrapper" name="home.footer">
        <action method="setElementClass"><value>l-two-col group</value></action>
            <block type="page/html_wrapper" name="home.footer.main">
                <action method="setElementClass"><value>l-main</value></action>
                <block type="page/html" name="featured_products" template="catalog/category/favourites.phtml" as="featured_products" />
            </block>        
            <block type="page/html_wrapper" name="home.footer.side">
            <action method="setElementClass"><value>l-sidebar</value></action>
                <block type="vertnav/navigation" name="catalog.vertnav" as="vertnav" template="vertnav/left.phtml">
                    <action method="setCategoryId"><category_id>3</category_id></action>
                </block>
            </block>
        </block>
    </reference>
</cms_index_index>

I have the below code in a module layout xml file which is correctly replacing the 'promos' block but I can't get it to do the same for the block named "featured_products".

<cms_index_index translate="label">
    <remove name="promos"></remove>
    <reference name="content">
        <block type="page/html" template="cms/promos/homepage-usa.phtml" as="promos" />
    </reference> 
</cms_index_index>

Does anyone know how I can replace the featured_products bloc in the same way as I have already done for the promos block?

I have tried:

<reference name="content">
    <block type="page/html" template="cms/promos/homepage-usa.phtml" as="promos" />
        <reference name="home.footer">
            <reference name="home.footer.main">
                <block type="page/html" name="featured_products1" template="catalog/category/favourites-usa.phtml" as="featured_products1" /> 
            </reference> 
        </reference>  
</reference> 

Thanks in advance,

Dave

Upvotes: 1

Views: 460

Answers (1)

benmarks
benmarks

Reputation: 23205

Whereas you are in local.xml, I'm not sure why you aren't just removing the directives. In any event:

  1. <remove name="featured_products"/> or

    <action method="unsetChild" block="home.footer.main"><child>featured_products</child></action>
    
  2. You should always add a name attribute to your block.

Upvotes: 1

Related Questions