How to get a block in any where?

Share

By the normal way, you can get a block by using object Layout.

For example,  in a controller:

$this->getLayout()->createBlock(‘module_name/block_name’);

It is the same with a block or a template file.

But if you want to get a block in a helper, model or any where, what way?

In this case, you can use: Mage::app()->getBlockSingleton(‘module_name/block_name’);

Leave a Reply

You must be logged in to post a comment.