Remove navigation links from My Account

后端 未结 11 730
挽巷
挽巷 2020-12-25 08:22

I am running Mage 1.5.0.1 and I am trying to remove the navigation links from the My Account section.

My local.xml has the following which works fine:



        
相关标签:
11条回答
  • 2020-12-25 08:54

    I had a similar problem, and I didn't want to comment out addLink node because we want to implement our changes in local.xml only. Ended up writing a small module to do it:

    app\etc\modules\Stackoverflow_Customerlinks.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Stackoverflow_Customerlinks>
                <active>true</active>
                <codePool>local</codePool>
            </Stackoverflow_Customerlinks>
        </modules>
    </config>
    

    app\code\local\Stackoverflow\Customerlinks\Block\Account\Navigation.php:

    <?php
    
    class Stackoverflow_Customerlinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {
    
        public function removeLinkByName($name) {
            unset($this->_links[$name]);
        }
    
    }
    

    app\code\local\Stackoverflow\Customerlinks\etc\config.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <global>
            <blocks>
                <customer>
                    <rewrite>
                        <account_navigation>Stackoverflow_Customerlinks_Block_Account_Navigation</account_navigation>
                    </rewrite>
                </customer>
            </blocks>
        </global>
    </config>
    

    After that, you can simply make the changes through local.xml:

    <customer_account>
        <reference name="customer_account_navigation">
            <action method="removeLinkByName"><name>recurring_profiles</name></action>
            <action method="removeLinkByName"><name>billing_agreements</name></action>
        </reference>
    </customer_account>
    

    Have fun :)

    0 讨论(0)
  • 2020-12-25 08:54

    Just to inform you guys about all the links in the navigation menu. To remove all links in local.xml:

    <?xml version="1.0"?>
    <layout version="0.1.0">
        <customer_account>
            <reference name="customer_account_navigation" >
                    <!-- remove the link using your custom method -->
                    <action method="removeLinkByName"><name>recurring_profiles</name></action>
                    <action method="removeLinkByName"><name>billing_agreements</name></action>
                    <action method="removeLinkByName"><name>reviews</name></action>
                    <action method="removeLinkByName"><name>downloadable_products</name></action>
                    <action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>
    
                    <action method="removeLinkByName"><name>account</name></action>
                    <action method="removeLinkByName"><name>account_edit</name></action>
                    <action method="removeLinkByName"><name>address_book</name></action>
                    <action method="removeLinkByName"><name>orders</name></action>
                    <action method="removeLinkByName"><name>tags</name></action>
                    <action method="removeLinkByName"><name>wishlist</name></action>
                    <action method="removeLinkByName"><name>newsletter</name></action>
    
            </reference>
        </customer_account>
    </layout>
    

    Thanks for your answer Daniel Sloof

    0 讨论(0)
  • 2020-12-25 08:58

    This module makes functionality ordering or show the links of my own, does not make for layout and phtml overwrites the block and makes all the logic there.

    http://www.magentocommerce.com/magento-connect/customer-navigation.html

    • The cleanest solution would be to make an overwrite of the box and add a method to remove links from layout.
    0 讨论(0)
  • 2020-12-25 08:58

    My Account Navigation links comes from customer.xml file.

                <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                    <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                    <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                    <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
                </block>
    
    0 讨论(0)
  • 2020-12-25 08:59

    By default, we don't have such method as "removeLink". Therefore, the trick is to remove the whole block using "unsetChild" approach and add the needed links block back with our own links added to it in local.xml

    <customer_account translate="label">
            <reference name="left">
                <!--Unset the whole block then add back later-->
                <action method="unsetChild"><name>customer_account_navigation</name></action>
                <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                    <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                    <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                    <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
                    <action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>My Orders</label></action>
                    <action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
                    <action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Favorite</label></action>
                    <action method="addLink" translate="label" module="newsletter"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
                </block>
                <remove name="catalog.compare.sidebar"/>
            </reference>
        </customer_account>
    
    0 讨论(0)
  • 2020-12-25 08:59

    You can use that:

        <customer_account>
            <action method="unsetChild"><name>customer_account_navigation</name></action>
                <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                    <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                    <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
    ...
                </block>
         </customer_account>
    

    Rewriting is not solution...

    0 讨论(0)
提交回复
热议问题