Search code examples
templatesmagentomethodsblockphp

Magento - Accessing php block class from template phtml file


I came across a way of accessing BLOCK classes (from a module)...in a phtml file. I could basically use '$var = Mage::blahblah....' and get access to any Block file in the module.

I didnt save this stmt, now i need to use it again, and cant find the info i need.

Does anyone know what the statment would be?

many thanks


Solution

  • Block class instances can be instantiated anywhere like so:

    Mage::app()->getLayout()->createBlock('core/template')->...;
    //or $this->getLayout()->createBlock('core/template')->...;
    //or $this->getLayout()->getBlock('block_name_loaded_in_controller_or_layout_or...');