Removing a block nested in a block through the local.xml file

I am trying to use the local.xml file (where all my updates are for the layout) to remove a block that is nested in another block. I can easily remove a block using the <remove> tag or using the unsetChild method, but I cannot delete a block that is nested in another block.

Here is the line of code I'm trying to delete (located in the customer.xml file). In particular, this is a 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 understand that this is not working right now, but here is my starting point (located in the 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.

+3
source share
4 answers

, . , . .

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

, . :

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

, , .

+1

, , 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.xml

<block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>

, . 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"/>

customer/account/dashboard/info.phtml , , :

<?php if( $this->isNewsletterEnabled() ): ?>
0
source

To remove Newsletter block with DashBoard Customer, you must modify the file

application / interface / YourTemplate / template / client / account / panel / info.phtml

and delete this block of code

<?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; ?>
0
source

Source: https://habr.com/ru/post/1754310/


All Articles