How To Rewrite Core Block – Rewritting Footer Block

Prerequisities

Which block to override

I decided that I want to replace core footer with image from my favorite movie. When you see open your page, you will see that footer’s block is Mage_Page_Block_Html_Footer.

Create the block

We will create our own Block now. Important thing is that our Block has to extends Mage_Page_Block_Html_Footer – the one we are going to override. It has to be placed in same directory and has the same name.

When you know the Block name, it’s very easy to find out where the block is located.

Which means that we need to create in our module’s file /Block/Html/Footer.php

For now we will copy all original Footer.php file from core, but with one change. We have to change Block class name. Final file will look like this

Replace old block with new one

It’s nice that we have created new block, but we need tell Magento that we want to load this block instead of the core one. We can do that in our module’s /etc/config.xml which will ends up looking like this