Get Magento Block content in template file

There is an easy way that can get any block html content in your custom template file (*.phtml):

  1. <?php echo $this->getLayout()->createBlock('Mage_Block_Class', 'block-name')->setData('template', 'template-file.phtml')->toHtml() ?>
Hide/show line number

This code above return the content of block which its type is Mage_Block_Class and using template 'template-file.phtml' to generate html code