Bryan Seeds


Custom Magento Module for CMS Page

Today just wanted to discuss how to make a custom Magento module that will allow you to make your own blocks to load into a CMS page using the layout updates.  Really not going to get in depth in the the Models and controllers part of the module creation, going to save that for another time..  anyhow here it is.

First let's create the file to enable the module in magento :


<?xml version="1.0"?>

Next, we are just going to create a configuration file to define the Block configuration only at this point, for our module :


<?xml version="1.0"?>

Now, let's go ahead and create our own Block class code to define the object used for our CMS/template page.


class <Namespace>_<ModuleName>_Block_MyBlock extends Mage_Core_Block_Abstract
public function __construct()
// any instantiation code here
protected function _toHtml()
// by overriding this method, you can define here everything you will render to browser, and use the inherited methods and accessors i.e. - $this->get[ParamName]()
return $html;

Last thing is to just throw this line into the CMS page content text area to load this custom Magento Block module.

{{block type="[namespace]_[modulename]/myblock" param1="value" param2="value"}}

So, that's it in a nutshell.. I will expand on this later for those who need more =)