Friday, April 6, 2012

How to Change the Footer Links in Magento

Magento’s XML layout and template framework and the flexibility that it brings is awesome, but unfortunately it does come with its own learning curve. This can take some time getting used to if you’re unfamiliar with Zend Framework and can turn the most trivial of tasks like modifying the links in the footer of a page somewhat more involved.
So let’s have a look at template/page/html/footer.phtml
You will be able to see that this gives us the footer div and loads most of the content through:

<?php echo $this->getChildHtml() ?>
 
You can then create your list of links as appropriate in the 
Magento backend, the default footer block contains:
 
<ul>
    <li>
<a href="{{store direct_url="about-magento-demo-store"}}">
 About Us</a></li>
    <li class="last">
<a href="{{store direct_url="customer-service"}}"> 
        Customer Service</a></li>
</ul>
 
There are a couple of reasons why it’s great to edit the footer links in this way. One is that the store owner can easily change the footer at a later date without needing a professional to hand. Another, is the flexibility to add different content if you so wish, it doesn’t have to be a simple list of links.
Another block with a “footer” reference can be found in page.xml:

<block type="page/html_footer" name="footer" as="footer" 
       template="page/html/footer.phtml">
    <block type="page/template_links" name="footer_links" 
 as="footer_links" template="page/template/links.phtml"/>
</block>
 
In the page/template/links.phtml file we can see 
a function call to $this->getLinks(); 

 
 

10 comments: