Editing Magento’s Footer Links

To follow up on our post about editing Magento’s top links, I thought I might as well write an article about editing the footer links while I’m at it.  I’d recommend reading our post about using a local.xml file before getting started on this post.  This post might not make much sense until you read it. [NOTE: This specific example assumes you are using the blank theme. Layout handles may differ from theme to theme.]

In local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="footer_links">
            <!-- Add custom links. Pretty self-explanatory.
            Dig into app/code/core/Mage/Page/Block/Template/Links.php for more info -->
            <action method="addLink" translate="label title">
                <label>About Us</label>
                <url>about</url>  <!-- can use a full url if not using urlParams below -->
                <title>About Us</title>
                <prepare>true</prepare> <!-- set true if adding base url param -->
                <urlParams helper="core/url/getHomeUrl"/> <!-- base url - thanks @Russ! -->
                <position>1</position>
                <liParams/>
                <aParams>'class="top-link-about-us"'</aParams>
                <beforeText></beforeText>
                <afterText></afterText>
            </action>
 
            <!-- Remove 'Site Map' Link - Default Position: 10
            Original link adding in catalog.xml -->
            <action method="removeLinkByUrl"><url helper="catalog/map/getCategoryUrl" /></action>
 
            <!-- Remove 'Search Terms' Link - Default Position: 20
            Original link adding in catalogsearch.xml-->
            <action method="removeLinkByUrl"><url helper="catalogsearch/getSearchTermUrl" /></action>
 
            <!-- Remove 'Advanced Search' - Default Position: 30
            Original link adding in catalogsearch.xml-->
            <action method="removeLinkByUrl"><url helper="catalogsearch/getAdvancedSearchUrl" /></action>
 
            <!-- Remove 'Contact Us' link - Original link in contacts.xml
            <!-- Best bet to go to Magento's Admin > System > Configuration > (left sidebar) Contacts
            > Contact Us Enabled = NO -->
            <!-- You can pass the full url, which is a hassle if you have dev and stage sites -->
            <action method="removeLinkByUrl"><url>http://YOUR_SITE.com/contacts/</url></action>
            <!-- see comments below for making a custom helper to remove contacts link
            no matter what your base url is  -->
	</reference>
 
        <!-- By default, Magento sets a static footer block. Find it in the admin under
        CMS > Static Blocks.
	<reference name="footer">
            <!-- Remove Magento's default static block and use the 'addLink' method above
            to add your custom and inline links.  I use the 'unsetChild' method as often as
            possible as opposed using the more final <remove name="cms_footer_links"/>
            just in case I want to add the block somewhere else -->
            <action method="unsetChild"><name>cms_footer_links</name></action>
 
            <!-- Remove all the other Magento links - "Site Map, Search Terms, Advanced Search, and
            Contact Us" -->
            <action method="unsetChild"><name>footer_links</name></action> <!-- Magento 1.4.x -->
	</reference>
</default>
</layout>

If all else fails, you can edit template/page/template/links.phtml. However, if you can make all your changes in local.xml, your life will be so much easier when it comes to upgrading Magento and making future edits.

17 Responses to “Editing Magento’s Footer Links”

  1. Are you using Magento 1.4 for this example. It seems like the current version doesnt have layout.xml.. its possible this may have changed – I am using the blank theme… its in the catalog now!

  2. @nolawi – Yes, this example is for Magento 1.3.2.4. Magento themes have never shipped with blank copies of local.xml. You have to create this layout file in your custom layout folder. So if you have the following structure:

    /app/design/frontend/CUSTOM_INTERFACE/CUSTOM_THEME/

    you would create the following file:

    /app/design/frontend/CUSTOM_INTERFACE/CUSTOM_THEME/layout/local.xml

  3. Hi
    I’m using 1.4.

    This
    cms_footer_links
    didn’t work for me to remove the footer.

    However, the real issue is with contacts (god knows why they made it so hard to change) because it will not adopt the new theme I just downloaded! Like everyone else, I really don’t want to mess with the code code so local.xml seemed like a gift from heaven – except we can’t get rid of contacts!

    Any other ideas grately appreciated,

    Jerry

  4. With 1.4 – to get rid of all footer links – in local.xml, change:

    <action method="unsetChild"><name>cms_footer_links</name></action>

    to:

    <action method="unsetChild"><name>footer_links</name></action>

    If you know how to make a custom module and want to get rid of JUST the contacts link:

    in app/code/local/CUSTOMNAME/MODULENAME/Helper/Data.php:

    public function getContactsUrl() {
            return Mage::getBaseUrl() . 'contacts/';
    }

    and in local.xml:

    <default>
    ...
        <reference name="footer_links">
            <action method="removeLinkByUrl"><url helper="modulename/data/getContactsUrl" /></action>
        </reference>
    ...
    </default>

    NOTE: make sure your modulename is lowercase

  5. Should this

    be

    instead?
    The “Beforetex” statement I am referring here…

    Also what do they mean actually?
    And how can I break down the footer links into two lines?
    Thanks!

  6. beforeText and afterText is for adding anything before or after your link.

    Say you wanted to wrap your link in a span tag:

    <action method="addLink" translate="label title">
      <label>About Us</label>
      <url>about</url>  
      <title>About Us</title>
      <prepare>true</prepare> 
      <urlParams helper="core/url/getHomeUrl"/> 
      <position>1</position>
      <liParams/>
      <aParams>'class="top-link-about-us"'</aParams>
      <beforeText>&lt;span class="whatever"&gt;</beforeText>
      <afterText>&lt;/span&gt;</afterText>
    </action>

    will make a link like this:

    <span class="whatever"><a href="[HOME_URL]/about" rel="nofollow">About Us</a></span>

    NOTE: that – rel=”nofollow” – won’t show up. our thing automatically adds it and i can’t get rid of it.

  7. Thanks! This is helpful.

    So does it mean I can do sth like to break the footer into two parts?

    ……
    < br / >

    This seems like a silly method to me….
    Any thought?
    Thanks.

  8. Yes Gary, I don’t see why not…

  9. Thanks for more info, but I’m having some issues (1.4.1.0):

    I’m trying to remove the CMS Static Block, but it’s removing the links.phtml sourced links instead of the CMS block:

    footer_links

    Thanks,
    Rick

  10. footer_links

  11. one last try:

    footer_links

  12. @Rick – I’m sorry about the confusion – my post was incorrect. Try this:

    ...
    <reference name="footer">
        <action method="unsetChild"><name>cms_footer_links</name></action>
    </reference>
    ...
  13. thanks kkirchner, figured that out with some trial and error. good work.

  14. Hey K,

    I tried setting up a custom module to remove the contacts link by creating the xml fil with my Namespace_Module.xml, saving it in etc/modules/ and then creating the directory structure under code/local with my Namespace/Module/Helper/Data.php and used the above code you provided and then tried to remove the contacts link by URL helper, and it doesn’t work.

    Anything I’m missing in that sequence for creating the custom module? In Config > Advanced >Advanced I see my module in the list, but the function isn’t working.

    Thanks

  15. Rick – did you wrap the above function in a class like this:

    class Namespace_Module_Helper_Data extends Mage_Core_Helper_Abstract
    {
        public function getContactsUrl() {
            return Mage::getBaseUrl() . 'contacts/';
        }
    }

    also, did you create a config.xml file in app/code/Namespace/Module/etc/ ? It would look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Namespace_Module>
                <version>1.0.1</version>
            </Namespace_Module>
        </modules>
     
        <global>
            <helpers>
                <module>
                    <class>Namespace_Module_Helper</class>
                </module>
            </helpers>
        </global>
    </config>

    The <module> tag inside helpers is the lowercase name of your custom module.

  16. Let’s see if your code works for me… Got it to work. My error was in my etc config.xml file.

    app/etc/modules/Dboxx_Contacts.xml

    true
    local

    app/code/local/Dboxx/Contacts/etc/config.xml

    0.1.0

    Dboxx_Contacts_Helper

    app/code/local/Dboxx/Contacts/Helper/Data.php

    and in local.xml trying to remove it with

    cms_footer_links

    thanks for the walkthrough :)

  17. Hi there! I’ve just tried to build a custom module to get rid of JUST the contacts link, but no luck… Can anybody help me on how to build it or post the code for it?

Comment Form

For Code: Use the html code for < & >.  i.e. "&lt;YOUR_TAG&gt; ...your code... &lt;/YOUR_TAG&gt;"

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Call us at 417-597-3397, email us at sales@classyllama.com, or use this form to contact us:

  1. (required)
  2. (required)
 

cforms contact form by delicious:days

Full builds (design and development) start at $70k