I am trying to remove links on my account navigation. I looked at the customer/account/navigation.phtml template. The template grabs links by $this->getLinks(). How do I edit getLinks() method so that I can remove some of links?
If you want to selectively remove links without having to copy/edit entire xml files, a nice solution can be found in this post in the magento forums
In this solution, you override the Mage_Customer_Block_Account_Navigation
block with a local version, that adds a removeLinkByName
method, which you then use in your layout.xml
files, like so:
<?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>
</reference>
</customer_account>
</layout>
The answer to your question is ultimately, it depends. The links in that navigation are added via different layout XML files. Here's the code that first defines the block in layout/customer.xml
. Notice that it also defines some links to add to the menu:
<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>
Other menu items are defined in other layout files. For example, the Reviews module uses layout/review.xml
to define its layout, and contains the following:
<customer_account>
<!-- Mage_Review -->
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
</reference>
</customer_account>
To remove this link, just comment out or remove the <action method=...>
tag and the menu item will disappear. If you want to find all menu items at once, use your favorite file search and find any instances of name="customer_account_navigation"
, which is the handle that Magento uses for that navigation block.
The easiest way to remove any link from the My Account panel in Magento is to first copy:
app/design/frontend/base/default/template/customer/account/navigation.phtml
to
app/design/frontend/enterprise/YOURSITE/template/customer/account/navigation.phtml
Open the file and fine this line, it should be around line 34:
<?php $_index = 1; ?>
Right below it add this:
<?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
unset($_links['tags']); /* My Tags */
unset($_links['invitations']); /* My Invitations */
unset($_links['enterprise_customerbalance']); /* Store Credit */
unset($_links['OAuth Customer Tokens']); /* My Applications */
unset($_links['enterprise_reward']); /* Reward Points */
unset($_links['giftregistry']); /* Gift Registry */
unset($_links['downloadable_products']); /* My Downloadable Products */
unset($_links['recurring_profiles']); /* Recurring Profiles */
unset($_links['billing_agreements']); /* Billing Agreements */
unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
?>
Just remove any of the links here that you DO want to appear.
You can also disable the menu items through the backend, without having to touch any code. Go into:
System > Configuration > Advanced
You'll be presented with a long list of options. Here are some of the key modules to set to 'Disabled' :
Mage_Downloadable -> My Downloadable Products
Mage_Newsletter -> My Newsletter
Mage_Review -> My Reviews
Mage_Tag -> My Tags
Mage_Wishlist -> My Wishlist
I also disabled Mage_Poll, as it has a tendency to show up in other page templates and can be annoying if you're not using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With