views:

21

answers:

1

Hello,

I'm trying to use my local.xml file (where I do all my updates to the layout) to remove a block that is nested in another block. I can easily remove a block via the <remove> tag, or using the unsetChild method, but I can't seem to remove a block that is nested in another block.

Here is the line of code I am trying to remove (located in the customer.xml file). In particular, it's the block called "customer_account_dashboard_newsletter"

<customer_account_index translate="label">
        <label>Customer My Account Dashboard</label>
        <update handle="customer_account"/>
        <!-- Mage_Customer -->
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <reference name="my.account.wrapper">
            <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
                <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
                <block type="core/template" name="customer_account_dashboard_top" as="top" />
                <block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
                <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
                <block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
                <block type="core/template" name="customer_account_dashboard_info1" as="info1" />
                <block type="core/template" name="customer_account_dashboard_info2" as="info2" />
            </block>
        </reference>

    </customer_account_index>

I realize this doesn't work right now, but here is my starting point (located in my local.xml file):

<customer_account_index>
    <reference name="my.account.wrapper">
            <action method="unsetChild"><name>customer_account_dashboard_newsletter</name></action>
    </reference>
</customer_account_index>

Any thoughts? Thank you.

A: 

I think you're referencing the wrong block. You have to reference the parent block of the block you want to remove. You are referencing the parent's parent block.

<customer_account_index>
  <reference name="customer_account_dashboard">
    <action method="unsetChild"><name>customer_account_dashboard_newsletter</name></action>
  </reference>
</customer_account_index>
Thomas