Magento: Remove all toplinks via local.xml

If you Google trying to fin out the best way to remove all the toplinks from the masthead of your Magento store you will be presented with a rash of different options on how and how not to do it. As always with Magento, there’s a number of ways to skin a cat – some of the ones I found ranged from easy and efficient to completely ludicrous. Particularly ott are the ones suggesting it be done by modifying template files, but you also see suggestions about modifying/overriding multiple layout files, or disabling modules through the Advanced system config menu in the backend.

You don’t need to do any of that, your theme (should) have it’s own local.xml file, you can handle it there using the following code;

<?xml version="1.0"?>
<layout version="0.1.0">

	<default>

        <!-- Top links (user menu) ====================================================================== -->
        <reference name="top.links">
                            
            <!-- Remove cart, checkout and wishlist top links -->
            <remove name="checkout_cart_link" />
            <remove name="wishlist_link" />

            <!-- Remove my account top links -->
            <action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>

        </reference>

	</default>

        <!-- getting rid of login logout links in top .links -->
        <customer_logged_in>
            <reference name="top.links">
                <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
            </reference>
        </customer_logged_in>
        <customer_logged_out>
            <reference name="top.links">
                <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
            </reference>
        </customer_logged_out>


</layout>