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! --> <!-- there are a few param you can send to do different things in <urlParams> dig into app/code/core/Mage/Core/Model/Url.php, around line 803 --> <!-- below adds #add-fragment to the end of your url --> <!-- <urlParams><_fragment>add-fragment</_fragment></urlParams> --> <!-- below adds ?add-query to the end of your url --> <!-- <urlParams><_query>add-fragment</_query></urlParams> --> <!-- below gives you a new session id (i think...)--> <!-- <urlParams><_nosid>true</_nosid></urlParams> --> <!-- below replaces double quotes, single quotes, greater than, and less than signs to their respective url escaped replacements (%22, %27, %3E, %3C) --> <!-- <urlParams><_escape>i'm-a-blog-url</_escape></urlParams> --> <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.
Posted on March 2, 2010
Posted by Kevin Kirchner
Add comment
Follow Us
Popular Posts
Blog Categories
- Design (4)
- Development (13)
- Magento Development (32)
- PHP (5)
- Security (0)
- E-Commerce (6)
- General Business (6)
- Llama Culture (3)
- Magento (54)
- Management (4)
- Wiz (3)
- Online Marketing (1)
- Productivity (2)
- Uncategorized (2)



Comments
This was a massive help today
This was a massive help today in clearing up some of the basic logic working behind the scenes. A definite bookmark. Thanks
I want to place My Cart on my
I want to place My Cart on my left tool bar . I have made as reference type as left but still it is not showing on my left Bar also currency search bar is not showing on the header section....Could U help me.....
thanks in advance.............
Is there a way to remove
Is there a way to remove "orders and Return" link from admin console? something like enable/disable option? I have my hosting through magento go. They don't give access to these xml files.
I am trying to change the
I am trying to change the site map/search terms/contact us links at the bottom and came across this article. Still having difficulty figuring it out.
Sorry, didn't get the code
Sorry, didn't get the code right. The link is defined like this: http://pastebin.com/vD5EZHMH
Great article. In Magento
Great article. In Magento 1.6.1 there is a new footer link: Orders and Returns. It is defined like this in sales.xml:
return_link
How can you remove this link from local.xml?
Awesome - thanks for the for
Awesome - thanks for the for kind words!
Man you rock! I have seen
Man you rock! I have seen hundreds of xml files and ways to do this things, and whenever I find it in your page it just works.
All things I have tested from your scripts still work on 1.6.
Thanks for sharing!
Good article. Action method
Good article. Action method "removeLinkByUrl" (footer_links) working great in Magento 1.5
@Tim - Set up a new theme for
@Tim - Set up a new theme for each store view and have it default to your main theme. (You can configure your themes in System > Configuration > Design (left sidebar) > Themes (main content)) In your new theme you can have just a local.xml file in your layout (you'll probably have a locale directory too). In that local.xml you can call different static blocks for your footer or add and remove links in your footer.
Hope that helps.
Great post! Tnx! You
Great post! Tnx!
You forgot to close a comment in your main piece of code.
(almost at the end at : By default, Magento sets a static footer block. Find it in the admin under CMS - Static Blocks.
I would very much like to know if it is easy to use different footers for different STORE VIEWS.
In that case I could easily link the footers to different pages (in different languages).
Thanks in advance...
@Dennis - if you try to
@Dennis - if you try to purposely error out your local.xml (i.e. leave off a closing '<') but your site still runs fine, then you haven't set the right theme in System > Configuration > Design (sidebar). If you're not running the default package then app/design/default/... won't work. Also check the themes are set to your_theme_name at least for 'Layout'.
Hi all, it doesn't seem that
Hi all, it doesn't seem that the local.xml file is working properly for me.... I have my directories all setup properly:
app/design/default/theme_name/layout/local.xml I copied the code exactly as it is here and nothing is happening. I am not caching the site so I'm not entirely sure what the issues, hope someone can steer me in the right direction.
Thanks...
@Peter, Just use the
@Peter, Just use the translate inline tool for changing "Contact Us" to "contact".
1. From the admin, System > Configuration > (bottom left sidebar) Developer, change configuration scope to your store (it's the drop down at the top of the left sidebar), and turn on translate inline for frontend.
1a. In "Developer Client Restrictions", above Translate inline, you can restrict the edits to only your IP (highly recommended if you're editing a live site!)
2. After you save, go to your homepage and hover over "Contact Us".
3. It should be outlined in red and a little book should appear on hover. Click the book and change "Contact Us" to "contact".
4. Don't forget to go back to you Configuration and turn it off when you're finished.
For separators, we'll usually style the links in css with {display:block; border-left:1px solid #000} or make a background image for the separators: {background:url(path/to/image.png) 100% 0 no-repeat}. Then for the last link you will need to add a "last" class and style it without the border or background image. Say you added the last link:
Last Link Label
last-link-url
Last Link Title
true
200
class="last"
|
See how I also added the "|" in the <beforeText> tag? That's another way to add a separator.
I forgot to ask, is it
I forgot to ask, is it possible to add a separator "|" between the links?
HI, great post! How can I
HI, great post!
How can I change "Contact Us" to just "contact" using the same approach?
Thanks,
Peter.
Hi there! I've just tried to
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?
Let's see if your code works
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 :)
Rick - did you wrap the above
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"?>
1.0.1
Namespace_Module_Helper
The <module> tag inside helpers is the lowercase name of your custom module.
Hey K, I tried setting up
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
thanks kkirchner, figured
thanks kkirchner, figured that out with some trial and error. good work.
@Rick - I'm sorry about the
@Rick - I'm sorry about the confusion - my post was incorrect. Try this:
...
cms_footer_links
...
one last try: footer_links
one last try:
footer_links
footer_links
footer_links
Thanks for more info, but I'm
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
Yes Gary, I don't see why
Yes Gary, I don't see why not...
Thanks! This is
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.
beforeText and afterText is
beforeText and afterText is for adding anything before or after your link.
Say you wanted to wrap your link in a span tag:
About Us
about
About Us
true
1
class="top-link-about-us"
<span class="whatever">
</span>
will make a link like this:
About Us
NOTE: that - rel="nofollow" - won't show up. our thing automatically adds it and i can't get rid of it.
Should this be
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!
With 1.4 - to get rid of all
With 1.4 - to get rid of all footer links - in local.xml, change:
cms_footer_links
to:
footer_links
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:
...
...
NOTE: make sure your modulename is lowercase
Hi I'm using 1.4.
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
@nolawi - Yes, this example
@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
Are you using Magento 1.4 for
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!