The Account Navigation <ul> has a number of account-related links. My tags, Product reviews,etc. But if we disable output for one of these modules on the backend, how do we remove it from the list?
But after searching for the getLinks() action, I ran into a deadend trying to find exactly where to remove the link from the list. I’ll keep searching, but anyone have any ideas?
If you would like to remove some links from the customer_account_navigation, just write your own module First, I tried to remove the links with some xml in my local.xml. I tried to remove the links with an action removeLinkByUrl. This resulted in an error report. The error report pointed me in the right direction. You have to add a method in the template file for the account navigation to remove the links with an action in your xml code.
create the following files and folders:
After you have created these files you can use the new method removeLinkByName to remove existing links from the account navigation.
The code in my local.xml looks like this:
Another way to remove these links is to unset them in the template file. Open up app/design/frontend/default/YOURTHEME/template/customer/account/navigation.html
Find:
<?php $_count = count($_links); ?>
And replace with:
<?php $_count = count($_links); unset($_links[\'recurring_profiles\']); unset($_links[\'billing_agreements\']); ?>
@cfr—great module! I would tweak just a bit, why copy the whole implementation of the block into the new class when you can just extend the existing class?
all other files the same, just shorten up Navigation.php like so:
<?php /** * adds removeLinkByName function to Navigation class, for use from a layout.xml file */ class mythemename_Customer_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation { /** * Removes link by name * * @param string $name * @return Mage_Page_Block_Template_Links */ public function removeLinkByName($name) { foreach ($this->_links as $k => $v) { if ($v->getName() == $name) { unset($this->_links[$k]); } }
@cfr—great module! I would tweak just a bit, why copy the whole implementation of the block into the new class when you can just extend the existing class?
all other files the same, just shorten up Navigation.php like so:
<?php /** * adds removeLinkByName function to Navigation class, for use from a layout.xml file */ class mythemename_Customer_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation { /** * Removes link by name * * @param string $name * @return Mage_Page_Block_Template_Links */ public function removeLinkByName($name) { foreach ($this->_links as $k => $v) { if ($v->getName() == $name) { unset($this->_links[$k]); } }
return $this; }
}
This seemed to work fine at first, but for some reason on certain hosting it removes the entire links block completely from the frontend. Any ideas why?
Just put this ‘app’ folder to your root directory. The local.xml file ( default/default/layout - you can change the path to your theme ) will hide ‘Recurring Profiles’ link and add new checkout link at last of the menu.
Just put this ‘app’ folder to your root directory. The local.xml file ( default/default/layout - you can change the path to your theme ) will hide ‘Recurring Profiles’ link and add new checkout link at last of the menu.
Hi hi_meral, thank you for sharing the files! It’s a great time saver for me.
Another way to remove these links is to unset them in the template file. Open up app/design/frontend/default/YOURTHEME/template/customer/account/navigation.html
Find:
<?php $_count = count($_links); ?>
And replace with:
<?php $_count = count($_links); unset($_links[\'recurring_profiles\']); unset($_links[\'billing_agreements\']); ?>
Thanks for that hint! Made my day. But I guess it should be without the backslashes like this:
Well...My requirement is to show account tab on the base of customer group. If customer group is “XYZ_GROUP” then only show a tab called ‘my_tab”. I got solution without overriding any block. So I made changes on navigation.phtml to remove the tab.