Magento Commerce is a powerful and scalable online shopping system (or Shopping cart + CMS).
It is developed using PHP with MVC (Model-View-Controller) framework. If you are not familiar with MVC framework it will take a long time for you to create custom block or fuction in Magento System.
Here are the 5 simple steps to demostrate how to create a custom block in Magento.
Step 1.) Creates your custom block file Customblock.xml into /app/etc/modules/ directory.
Code :
<?xml version="1.0"?>
<config>
<modules>
<Mage_Backlink>
<active>true</active>
<codePool>local</codePool>
</Mage_Backlink>
</modules>
</config>
** If your custom name = CustomBlock , you attribute should be <Mage_Custom_Block>**
Step 2.) Creates config.xml into /app/code/local/Mage/Customblock/etc/ directory
*Note : you have to create your custom block folder personally, eg, creates “Customeblock” folder.
<?xml version="1.0"?>
<config>
<global>
<blocks>
<backlink>
<class>Mage_Backlink_Block</class>
</backlink>
</blocks>
</global>
</config>
Step 3.) Creates your custom PHP script into /app/code/local/Mage/Customblock/Block/<function name>.php
Content :
class Mage_Backlink_Block_Listing extends Mage_Core_Block_Abstract
{
protected function _toHtml()
{
//$P=$this->getRequest()->getParams();
//$pageid =isset( $P['pid'] )?$P['pid']*1:0;
return $html;
}
}
Step 4.) Goto Magento Admin page, from the menu toolbar, choose CMS -> Manage Pages, Choose the page you want to edit, the paste the code into the content.
{{block type="backlink/listing" pid="6" }}








Excelent! i dont know why Magento documentation is so bad, I have to learn it from blogs like yours. Do you know any good reference book worth buying it?
Thanks!
kindly refer to the Magento documentation from official website.
It’s a nice article, but I see all the html special characters double-escaped – everything looks like & < etc. Makes it painful to read…
Hi Sam,
Thanks for your remind.
Hugo