Magento 通过local.xml文件删除嵌套在块中的块

Magento 通过local.xml文件删除嵌套在块中的块,magento,nested,block,Magento,Nested,Block,我试图使用local.xml文件(我在其中对布局进行所有更新)删除嵌套在另一个块中的块。我可以通过标记或使用unsetChild方法轻松删除块,但似乎无法删除嵌套在另一个块中的块 下面是我试图删除的代码行(位于customer.xml文件中)。特别是,它是一个名为“客户\账户\仪表板\时事通讯”的区块 客户我的帐户仪表板 第页/2列-left.phtml 我意识到这现在不起作用,但这里是我的出发点(位于我的local.xml文件中): 客户\账户\仪表板\时事通讯 有什么想法吗?谢谢。我

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

下面是我试图删除的代码行(位于customer.xml文件中)。特别是,它是一个名为“客户\账户\仪表板\时事通讯”的区块


客户我的帐户仪表板
第页/2列-left.phtml
我意识到这现在不起作用,但这里是我的出发点(位于我的local.xml文件中):


客户\账户\仪表板\时事通讯

有什么想法吗?谢谢。

我认为您引用的块是错误的。必须参照要删除的块的父块。您正在参照父对象的父块

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

客户\账户\仪表板\时事通讯

要在另一个块中取消设置块,必须嵌套引用。例如:

<catalog_product_view>
    <reference name="content">
        <reference name="product.info">
            <action method="unsetChild"><name>addtocart</name></action>
        </reference>
    </reference>
</catalog_product_view>

addtocart

此外,有时系统无法识别块名,因此必须在操作中使用别名。

通常,如果要删除嵌套块,还应在
local.xml
中嵌套引用,在这种情况下,正确的语法为:

<customer_account_index>
    <reference name="my.account.wrapper">
        <reference name="customer_account_dashboard">
            <remove name="customer_account_dashboard_newsletter" />
        </reference>
    </reference>
</customer_account_index>
不具有显示要删除的块的效果。但是该块被添加到
customer/account/dashboard/info.phtml
模板中,该模板包含在
customer.xml
中的前一行中:

<block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>

要从客户仪表板中删除新闻稿块,必须修改该文件

app/frontend/yourtemplate/template/customer/account/dashboard/info.phtml

并删除这段代码

<?php if( $this->isNewsletterEnabled() ): ?>
<div class="col-2">
    <div class="box">
        <div class="box-title">
            <h3><?php echo $this->__('Newsletters') ?></h3>
            <a href="<?php echo $this->getUrl('newsletter/manage') ?>"><?php echo $this->__('Edit') ?></a>
        </div>
        <div class="box-content">
            <p>
                <?php if( $this->getIsSubscribed() ): ?>
                    <?php echo $this->__("You are currently subscribed to 'General Subscription'.") ?>
                <?php else: ?>
                    <?php echo $this->__('You are currently not subscribed to any newsletter.') ?>
                <?php endif; ?>
            </p>
        </div>
    </div>
    <?php /* Extensions placeholder */ ?>
    <?php echo $this->getChildHtml('customer.account.dashboard.info.extra')?>
</div>
<?php endif; ?>


<block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
<block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
<?php if( $this->isNewsletterEnabled() ): ?>
<?php if( $this->isNewsletterEnabled() ): ?>
<div class="col-2">
    <div class="box">
        <div class="box-title">
            <h3><?php echo $this->__('Newsletters') ?></h3>
            <a href="<?php echo $this->getUrl('newsletter/manage') ?>"><?php echo $this->__('Edit') ?></a>
        </div>
        <div class="box-content">
            <p>
                <?php if( $this->getIsSubscribed() ): ?>
                    <?php echo $this->__("You are currently subscribed to 'General Subscription'.") ?>
                <?php else: ?>
                    <?php echo $this->__('You are currently not subscribed to any newsletter.') ?>
                <?php endif; ?>
            </p>
        </div>
    </div>
    <?php /* Extensions placeholder */ ?>
    <?php echo $this->getChildHtml('customer.account.dashboard.info.extra')?>
</div>
<?php endif; ?>