Wednesday, February 20, 2013

How to call a block directly from a .phtml file?

Sometimes you want to call a block inside a .phtml file without defining in layout. In this case, we can use a method called toHtml of a block.
Assume that we have a block called Mymodule and a template that is located at: mymodule/myblog.phtml
So to generate that block we use:
<?php echo $this->getLayout()->createBlock('mymodule/myblock')->setTemplate('mymodule/mybl

No comments:

Post a Comment