Ads

Monday, August 2, 2010

create Magento blocks and add into layout

The block is called from app/code/local/my_pack/my_module/controllers/IndexController.php file.

public function indexAction()
{
//Get current layout state
$this->loadLayout();

$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'your_block_name',
array('template' => 'my_pack/your_file_name.phtml')
);

$this->getLayout()->getBlock('content')->append($block);

$this->renderLayout();
}