Magento Certified Developer GuideCategory: 3.1 Design & LayoutHow can variables be passed to the block using the following methods?
Manish Prakash Staff asked 5 years ago

− From layout xml file
we can set variables and access function using the “action” directive

 <block type='core/template' name='test'>
     <action method='setTemplate'><template>page/html/test.phtml</template></action>
     <action method='setAge'><value>4</value></action>

− From controller

$this->getLayout()->getBlock('head')->setTitle('Test Title');

− From one block to another

$this->getLayout()->getBlock('head')->setTitle('Test Title');

− From an arbitrary location (for example, install/upgrade scripts, models)

Mage::getSingleton('core/layout')->getBlock('head')->setTitle('Test Title');