Editing the Footer in a stock magento build

Posted on 02. Sep, 2008 by Fido in Design, Magento

The items in the footer area are in two different locations. One part is a static block created within the magento admin area (CMS > Static Block). The other part is held in the related .phtml / .php / .xml files within the design files.

First off, the XML files

app/design/frontend/*/*/layout/page.xml
Here you will find some footer reference:

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
</block>

app/design/frontend/*/*/layout/cms.xml

<reference name="footer">
<block type="cms/block" name="cms_footer_links" before="footer_links">
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
</reference>

You can see that the footer area of each page (page.xml) adds footer links via:
app/design/frontend/*/*/template/page/html/footer.phtml
This file (footer.phtml) contains a method to get it’s children HTML as referenced in the page.xml file – ($this->getChildHtml();)
-app/design/frontend/*/*/template/page/switch.phtml
-app/design/frontend/*/*/template/page/template/links.phtml

footer.phtml is basically a “shell” which includes the “report bugs to magento” text. It also calls the getChildHtml method to get the rest in there.

One important part of the footer’s children HTML are the links:
The .phtml file , however, grabs links from the method “$this->getLinks()” found in the Block .php file controlling the template…. so the hunt begins.

The Block file controlling this template is:
app/code/core/mage/page/Template/Links.php
However, here you will find that this only has generic code for entering links! Where, then, are these links coming from? Well…a lot of places :(

Luckily I did the hunting for you:

<!--contacts.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
</reference>

<!--rss.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="rss" ifconfig="rss/config/active"><label>RSS</label><url>rss</url><title>RSS testing</title><prepare>true</prepare><urlParams/><position/><li/><a>class="link-feed"</a></action>
</reference>

<!--catalogsearch.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="catalogsearch" ifconfig="catalog/seo/search_terms"><label>Search Terms</label><url helper="catalogsearch/getSearchTermUrl" /><title>Search Terms</title></action>
<action method="addLink" translate="label title" module="catalogsearch"><label>Advanced Search</label><url helper="catalogsearch/getAdvancedSearchUrl" /><title>Advanced Search</title></action>
</reference>

<!--catalog.xml-->
<reference name="footer_links">
<action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map"><label>Site Map</label><url helper="catalog/map/getCategoryUrl" /><title>Site Map</title></action>
</reference>

These are all in .xml files so you can CRUD these footer links (CRUD = Create, Update, Delete).
They can also be created via PHP code, just as (as I mentioned already) you can with with many XML items (especially where you see the METHOD attribute/tag being used)

I believe that covers all the links created in the footer area! You can edit or remove each of these (or add them wherever you wish in XML! Don’t forget that these xml actions relate to real php methods (that’s the third time I mentioned this)! I have a code sample somewhere, I have to remember to get that and add it here. (Bug me if I don’t update this post for that!)

Now, as for the other links (About Us and Customer Service) they are merely created in the Admin section as mentioned. Admin > CMS > Static Blocks.
They are referenced in cms.xml as shown above. You can use this method to show static blocks creating in the CMS area of the admin section anywhere (the much-repeated emphasis on being able to use PHP code to do the job of the XML (or visa versa) is handy to add a static block somewhere in your code instead of using xml).

Tags: , , ,

44 Comments

Magento User

26. Sep, 2008

Thank you! That helped out greatly!

Herve

07. Oct, 2008

Thanks, great to see short example going stright to the point.

Could do with having it linked with the magento forum in fact

PixelWarrior

29. Jan, 2009

You sir, are a god

Nehal

10. Feb, 2009

Thanks for useful info i was damn searching for how to add static page to footer and finally i got it from you man

Again Thank you very much!

pavlentij

19. Mar, 2009

Thank’s, I’ve found here how to add class to top-link. Many thanks.

rickett

24. Mar, 2009

Thanks for the great writing. I’ve commented out the footer_links but they keep appearing in the footer. Is that the default template tossing that in there? I’m building off basic_template. Thanks!

minu

24. Mar, 2009

i want to dispaly a static block in header of page

shahriat

26. Mar, 2009

so far so good :)

Kris

01. Apr, 2009

Great article! (Is it me, or is Magento’s handling of links obtuse?)

So I’m trying to use XML to add links to the catalog.xml file. I want to add links to static CMS pages. Here’s what I have so far:

About UsAbout Us

But this doesn’t produce any results. Anyone have an idea why?

Thanks!

Kris

01. Apr, 2009

Great article! (Is it me, or is Magento’s handling of links obtuse?)

So I’m trying to use XML to add links to the catalog.xml file. I want to add links to static CMS pages. Here’s what I have so far:

“About Us3About Us”

(ignore the first and last quotes)

But this doesn’t produce any results. Anyone have an idea why?

Thanks!

BC

20. Apr, 2009

Could you do a video tutorial on this?

BC

21. Apr, 2009

I installed Magento using simplescripts at bluehost. Now, in my footer, there is a link to simplescripts.com. I cannot figure out where to find this link or how to delete it. Any help would be appreciated…

Fido

21. Apr, 2009

BC – We’d love to start doing some screencasts on this stuff. That might be in our future. As to your problem:

I suggest turning on template path hints (an option in the backend system options).

THis might give you a clue as to where to find the footer links.

They can be in many places, it depends on how bluehost added in the link.

It might be a HTML block created in the CMS system.
It might be hardcoded into a template (.phtml) file.
It may also be added via code in a module – you might want to check if bluehost has a module or any additional Magento options in the admin area.

Hope this helps!

Matt

08. Jun, 2009

Great explanation about the footer.

I modified my footer in my Magento store to make it with 4 columns.

You can have a look here: http://www.smartcoyote.com
the plugin is available

Emer

09. Jul, 2009

“I have a code sample somewhere, I have to remember to get that and add it here. (Bug me if I don’t update this post for that!)”
–> you mentioned we could bug you :) … this site is a very good resource for magento, thank you for the tutorials. i’m still new to magento and i find this app very interesting.

Mathias

30. Jul, 2009

Thanks, perfect :)

Name

20. Aug, 2009

God bless you!

Jürgen

21. Aug, 2009

Thanks a lot for sharing, just what I was looking for ;-)

Alvin Crespo

22. Aug, 2009

Hey, thanks for the help. I greatly appreciate it.

Name PakistaniMusic

23. Aug, 2009

Excellent tutorial really helped me alot.

Diego

23. Aug, 2009

how can I add rel=”nofollow” only to the top links and not to the bottom?

Micah

11. Sep, 2009

Thanks! I was looking all over for that solution!

Name Yasir

26. Oct, 2009

Thanks for the tutorial, would you please tell me how i can show the latest products in footer template file section so it will be shown on all pages ?

Roland

19. Nov, 2009

thanks to people like you, I have less headaches!
I am very grateful.

Alex Ciobica

01. Dec, 2009

The method in cms.xml simply adds the content of the static page in a certain block.
I think a more elegant solution would be to add the static page links to a certain block of type “page/template_link” using addLink.
Is that possible for static pages? Any ideas on how?

Thanks!

Timmey

13. Dec, 2009

Awesome Stuff! Directly added to my Bookmarks!
Thank you very much!

Anabel

05. Jan, 2010

You are my Heroe

Name Pascal

21. Jan, 2010

Hi, I would like to get “store switcher” to direct in new window in navigator: target=_blank.

Actualy my store switcher is in the footer.
In wich filescan I change it?

In advance thanks for your help!

Harry

29. Jan, 2010

Great stuff, Thank you.
I was initially planning on removing a link using your method but from reading your article had the idea to just place a and the end of my footer_links code I can have two rows right justified so it suited me better.

Thanks again.

Owen

06. Apr, 2010

thanks for this useful post! this is what i am looking for, i changed the footer links,it looks pretty good now!
thanks again!

Chetan

09. Apr, 2010

Thank you it help me a lot!

Can you please tell me how can we make a new page that show Magento cagetories with images and category description Thank you it help me a lot!

Great article!
thanks :)

Tom Coady

23. Apr, 2010

Found mine at app/design/frontend/default/magesupport/template/page/html/footer.phtml

guess that would be
app/design/frontend/default/*/template/page/html/footer.phtml
as a generic path?

Kevin

29. Jun, 2010

There’s a better way to edit the footer links (and the toplinks) in Magento without editing any core xml files that may need to be updated in a Magento upgrade. It uses a local.xml file.

Here’s a great article about how to implement a local.xml file. http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/

And here’s the article on editing the footer links. http://classyllama.com/development/magento-development/editing-magentos-footer-links/

Here’s the article about editing Magento’s top links. http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/

Glauco

06. Aug, 2010

Thanks, this is really helpful. The role of phtml and xml files in Magento is a confusing subject for the less technically minded of us.
I was looking for a way to display all the footer links on a single line (so you get a nice thin footer instead of a massive one) but if you simply comment out the lines that generate the second set of links and then enter them statically in the CMS block page, you get two sets of .first and .last CSS classes of links so the dividers are messed up. I devised a simple solution to this problem and the tutorial if anyone is interested is here: http://www.webrightnow.co.uk/magento-footer-links.html.

Glauco

06. Aug, 2010

Sorry the link I gave doesn’t work because of the full stop at the end. This is the correct one:
http://www.webrightnow.co.uk/magento-footer-links.html/

James Lee

17. Aug, 2010

how to use toplinks in header and footer?

Mark

24. Aug, 2010

do you know how to make those links active?

Favre Jerseys

01. Oct, 2010

thanks for the help

Flo

06. Oct, 2010

Thanks, buddy!

Mads Bang Jensen

28. Oct, 2010

Fantastic help. Thank you.

:S

09. Nov, 2010

you can edit the footers in the admin panel….. its a allot simpler than doing all this code

Vikings

09. Nov, 2010

thanksfor sharing

jess

21. Nov, 2010

Awesome thank you!!

jess

21. Nov, 2010

Still searching but thought I’d ask…. Any idea how to change the copyright in 1.4.1???

Leave a reply