I needed to swap out the default ‘top.links’ that are populated by ‘template/page/top.links.phtml’ and assorted ‘layout/*.xml’ files, respectively. In most installs, I create a ‘layout/local.xml’ that overrides existing xml layout files within Magento. In this particular case, I needed to remove the ‘My Account’, ‘Wishlist’, ‘Cart’ and ‘Checkout’ links. In addition, I needed to add a link to the ‘Contacts’ page and create the logic to turn back on the ‘Cart’ and ‘Checkout’ links at a later date.
All of this below should go into ‘path/to/magento/app/design/frontend/theme/theme_group/layout/local.xml’
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="root">
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>
<remove name="checkout_cart_link"/><!--Will remove both 'cart' and 'checkout'-->
<block type="checkout/links" name="checkout_cart_link_custom">
<action method="addCheckoutLink"></action><!--readding 'checkout'-->
<action method="addCartLink"></action><!--readding 'cart'-->
</block>
<remove name="wishlist_link"/>
<action method="addLink" module="contacts"><!--Add new link to 'contacts-->
<label>Email Us</label>
<url>contacts</url><!--any url from root or use 'helper' e.g. 'helper="customer/getLoginUrl"'-->
<prepare>true</prepare><!--setting to 'true' makes url absolute-->
<title>Email Us</title>
<position>100</position>
</action>
</reference>
</reference>
</default>
</layout>
I’m sure there is a more efficient way to do this, but as far as I can tell, it’s an adequate way to build out Magento functionality rather than hardcoding and overwriting. All you experienced Magento folk, please hit me up with some feedback.
Magento Minneapolis – Ecommerce Web Development
Need help setting up your online store with Magento? Our Minneapolis Magento web development team can create custom coding for your site. Give us a call at (763) 548-2297 or contact us online to request a free consultation. We’ve been managing our own ecommerce stores for over 10 years. Now let us do it for you!
