我正在尝试使用我的 local.xml 文件(我在其中对布局进行所有更新)来删除嵌套在另一个块中的块。我可以通过 标记或使用 unsetChild 方法轻松删除块,但我似乎无法删除嵌套在另一个块中的块。

这是我试图删除的代码行(位于 customer.xml 文件中)。特别是,它是名为“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>

我意识到这现在不起作用,但这是我的起点(位于我的 local.xml 文件中):
<customer_account_index>
    <reference name="my.account.wrapper">
            <action method="unsetChild"><name>customer_account_dashboard_newsletter</name></action>
    </reference>
</customer_account_index>

有什么想法吗?谢谢你。

最佳答案

我认为您引用了错误的块。您必须引用要删除的块的父块。您正在引用父级的父级块。

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

关于magento - 通过 local.xml 文件删除嵌套在块中的块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3232340/

10-13 00:38