Managing navigation links in the account dashboard

In this article I’ll demonstrate how to manage navigation links in the customer’s account dashboard: one way of removing new links from customer’s account dashboard which should be avoided and another way which is the way to go.

One approach to delete desired links would be to comment out the action that displays the link. As an example I’ll take “Account Information” link in account dashboard which is located in app/design/frontend/base/default/layout/customer.xml (line 230).

<action method=”addLink” translate=”label” module=”customer”><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>

However, editing core files in Magento is never a good idea. Instead of this approach we’ll use something different.
For start we’ll have to edit our config.xml file, we have to rewrite Magento’s core file.

<global>
<blocks>
<customer>
<rewrite>
<account_navigation>Inchoo_Core_Block_Customer_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
</global>

Next we have to define our layout xml file:

<frontend>
<layout>
<updates>
<inchoo_core>
<file>inchoo_core.xml</file>
</inchoo_core>
</updates>
</layout>
</frontend>

Next step would be to create Block/Customer/Account/Navigation.php with following class:

class Inchoo_Core_Block_Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation (H)
{
public function removeLinkByName($name) {
unset($this->_links[$name]);
}
}

Last thing we need to do is create layout xml file in app/design/frontend/default/default/layout/inchoo_core.xml:

<?xml version=”1.0″ ?> (H)
<layout version=”0.1.0″>
<customer_account translate=”label”>
<reference name=”customer_account_navigation”>
<action method=”removeLinkByName”><name>billing_agreements</name></action>
<action method=”removeLinkByName”><name>recurring_profiles</name></action>
<action method=”removeLinkByName”><name>tags</name></action>
<action method=”removeLinkByName”><name>wishlist</name></action>
<action method=”removeLinkByName”><name>OAuth Customer Tokens</name></action>
<action method=”removeLinkByName”><name>downloadable_products</name></action>
</reference>
</customer_account>
</layout>

Now for every link we want to remove from navigation we need to add navigation link name and write the name of that link inside name tag.
This is a list of all names for navigation links in account dashboard (in default order of their appearance):

  • account
  • account_edit
  • address_book
  • orders
  • billing_agreements
  • recurring_profiles
  • reviews
  • tags
  • wishlist
  • OAuth Customer Tokens
  • newsletter
  • downloadable_products

Adding new links to the navigation is even easier then removing them. All we need to do is add this code to our layout xml file:

<?xml version=”1.0″ ?> (H)
<layout version=”0.1.0″>
<customer_account translate=”label”>
<reference name=”customer_account_navigation”>
<action method=”addLink”><name>test checkout</name><path>checkout</path><label>Inchoo Checkout</label></action>
</reference>
</customer_account>
</layout>

End result should be like this

account-dashboard

We got this blog from Inchoo for more detail Click Here

Leave a Reply