Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Remove Links from Account Navigation List.. 
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

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?

Navigation.phtml grabs the data via:

<?$_links $this->getLinks();?>
                <?$_index 
1;?>
                <?$_count 
count($_links);?>
                <?foreach 
($_links as $_link):?>

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?

 
Magento Community Magento Community
Magento Community
Magento Community
 
FetchDesigns
Sr. Member
 
Avatar
Total Posts:  124
Joined:  2008-04-11
Chicago, IL
 

To remove the “My Tags” link you will need to edit… /app/design/frontend/default/default/layout/tag.xml

You can just comment out the action…

<!--
Customer account pagesrendered for all tabs in dashboard
-->

    <
customer_account>
        <!-- 
Mage_Tag -->
        <
reference name="customer_account_navigation">
            <!--<
action method="addLink" translate="label" module="tag"><name>tags</name><path>tag/customer/</path><label>My Tags</label></action>-->
        </
reference>
    </
customer_account>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Senetor
Sr. Member
 
Avatar
Total Posts:  259
Joined:  2009-03-26
Denmark
 

how to remove my downloadable products?

 
Magento Community Magento Community
Magento Community
Magento Community
 
FetchDesigns
Sr. Member
 
Avatar
Total Posts:  124
Joined:  2008-04-11
Chicago, IL
 

It’s basically the same idea only the file is… app/design/frontend/default/default/layout/downloadable.xml

Then just comment this out like so…

<!--
<
customer_account>
        <
reference name="customer_account_navigation">
             <
action method="addLink" translate="label" module="downloadable"><name>downloadable_products</name><path>downloadable/customer/products</path><label>My Downloadable Products</label></action>
        </
reference>
</
customer_account
-->

There is an open bug report about this here… http://www.magentocommerce.com/bug-tracking/issue?issue=5258 ... hopefully the Magento team can fix this so it only displays if your store actually has downloadable products.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cfr
Jr. Member
 
Total Posts:  5
Joined:  2010-06-28
 

If you would like to remove some links from the customer_account_navigation, just write your own module wink 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:

/app/code/local/mythemename/customer/block/account/navigation.php

class mythemename_Customer_Block_Account_Navigation extends Mage_Core_Block_Template
{

    
protected $_links = array();

    protected 
$_activeLink false;

    public function 
addLink($name$path$label$urlParams=array())
    
{
        $this
->_links[$name] = new Varien_Object(array(
            
'name' => $name,
            
'path' => $path,
            
'label' => $label,
            
'url' => $this->getUrl($path$urlParams),
        ));
        return 
$this;
    
}

    
public function setActive($path)
    
{
        $this
->_activeLink $this->_completePath($path);
        return 
$this;
    
}

    
public function getLinks()
    
{
        
return $this->_links;
    
}

    
public function isActive($link)
    
{
        
if (empty($this->_activeLink)) {
            $this
->_activeLink $this->getAction()->getFullActionName('/');
        
}
        
if ($this->_completePath($link->getPath()) == $this->_activeLink{
            
return true;
        
}
        
return false;
    
}

    
protected function _completePath($path)
    
{
        $path 
rtrim($path'/');
        switch (
sizeof(explode('/'$path))) {
            
case 1:
                
$path .= '/index';
                
// no break

            
case 2:
                
$path .= '/index';
        
}
        
return $path;
    
}
    
/**
     * 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;
    
}

}

/app/code/local/mythemename/customer/etc/config.xml

<?xml version="1.0"?>
<config>
    <global>
        <
blocks>
            <
customer>              
                   <
rewrite>
                        <
account_navigation>mythemename_Customer_Block_Account_Navigation</account_navigation>
                    </
rewrite>
            </
customer>
        </
blocks>
    </global>
</
config>

/app/etc/modules/mythemename.xml

<?xml version="1.0"?>
<config>
    <
modules>
       <
mythemename_Customer>
            <
active>true</active>
           <
codePool>local</codePool>
       </
mythemename_Customer>
    </
modules>
</
config>

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:

<?xml version="1.0"?>
<layout version="0.1.0">
   <
customer_account>
     <
reference name="customer_account_navigation">
                <
action method="removeLinkByName"><name>recurring_profiles</name></action>
                <
action method="removeLinkByName"><name>billing_agreements</name></action>
                <
action method="removeLinkByName"><name>downloadable_products</name></action>
        </
reference>   
    </
customer_account>
</
layout>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Tamayo
Member
 
Total Posts:  33
Joined:  2009-01-09
 

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\']); ?>

 
Magento Community Magento Community
Magento Community
Magento Community
 
tomj74
Jr. Member
 
Total Posts:  5
Joined:  2010-05-10
Berkeley California
 

@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;
    
}

}
 
Magento Community Magento Community
Magento Community
Magento Community
 
johnlouis
Sr. Member
 
Avatar
Total Posts:  92
Joined:  2008-08-27
 

@cfr thanks a lot It worked like a charm for me

 
Magento Community Magento Community
Magento Community
Magento Community
 
divinemonkey
Member
 
Avatar
Total Posts:  49
Joined:  2009-11-11
 
tomj74 - 22 November 2010 09:49 PM

@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?

 
Magento Community Magento Community
Magento Community
Magento Community
 
hi_meral
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2010-04-28
 

Let me share this.

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.

File Attachments
app.zip  (File Size: 4KB - Downloads: 727)
 
Magento Community Magento Community
Magento Community
Magento Community
 
webarton
Member
 
Total Posts:  45
Joined:  2011-02-03
 
hi_meral - 11 March 2011 12:24 AM

Let me share this.

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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hs037
Jr. Member
 
Total Posts:  7
Joined:  2011-05-11
 
Tamayo - 10 September 2010 04:19 PM

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:

<?php $_count count($_links); unset($_links['recurring_profiles']); unset($_links['billing_agreements']); ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
d8bhatta
Member
 
Total Posts:  44
Joined:  2009-06-11
 

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.

<?php
$groupId = Mage::getModel('customer/session')->getCustomerGroupId();
$customerGroupModel = Mage::getModel ('customer/group')->load ($groupId);

$code = $customerGroupModel->getCode();
if($code != "XYZ_GROUP") {
if(isset($_links['my_tab'])) {
unset($_links['my_tab']);
}
}
?>

I hope this idea will help somebody who want to remove tab on the base of customer group.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Mentor
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

I have developed an extension called Frontend Links Manager for this purpose:
http://www.magentocommerce.com/magento-connect/MagePsycho/extension/7905/frontend_links_manager
You can easily turn on/off the required customer navigational links via backend.

Cheers!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

I like this method from http://stackoverflow.com/questions/5887664/remove-navigation-links-from-my-account

<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>
            <
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=\"newsletter\"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
        </
block>
    </
customer_account>
 
Magento Community Magento Community
Magento Community
Magento Community
 
peterjaap
Jr. Member
 
Avatar
Total Posts:  28
Joined:  2010-03-26
Groningen, The Netherlands
 

I’ve made a bash script to automate this process and quickly remove those useless links; http://blog.blaakmeer.com/2012/02/easily-remove-my-account-dashboard-links/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2