Magento: Add/ Remove account dashboard navigation links
January 12, 2012 | In: Magento, php, web development, XML
We can add or remove anythings in magento core files but it is not a perfect solution. To make a perfect solution, we are creating a small module. By this module you will able to add / remove navigation links from customer account dashboard.
Firstly, we create a module XML file to access from local folder:
Step1: Create a file “Nos_Navigation.xml” in app\etc\modules\ folder
Step2: Put below code in this xml file
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Nos_Navigation> <active>true</active> <codePool>local</codePool> </Nos_Navigation> </modules> </config> |
Step3: Create a new file “app\code\local\Nos\Navigation\Block\Account\Navigation.php”
and put below code in this file:
<?php class Nos_Navigation_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation { // This function is use to remove a link from navigations list. public function removeLinkByName($name) { unset($this->_links[$name]); } } ?> |
Step4: Create a file: “app\code\local\Nos\Navigation\etc\config.xml”
<?xml version="1.0" encoding="UTF-8"?> <config> <global> <blocks> <customer> <rewrite> <account_navigation>Nos_Navigation_Block_Account_Navigation</account_navigation> </rewrite> </customer> </blocks> </global> </config> |
Step5: Now you can create your own local.xml file in your theme layout folder. If you have not idea that how you can create a local.xml file in your own theme folder then don’t worry 🙂
Step6: create a local.xml file in your “add/design/frontend/YOUR_THEME/default/layout/local.xml”
Step7: Put below code in your theme local.xml file:
<customer_account> <reference name="customer_account_navigation"> <action method="removeLinkByName"><name>tags</name></action> </reference> </customer_account> |
You can also add your own line to remove another links like: billing_agreements, wishlist, etc.
That’s it.