Send data from the controller to phtml
There are a couple of ways to do this.
Assign directly to the Block:
$block->assign($var);
or
$block->assign(array('myvar'=>'value','anothervar'=>true));
Then you can access it in the phtml file like this:
$this->myvar
Use the Mage registry:
Mage::register('custom_var', $var);
and then use it like:
$var = Mage::registry('custom_var');
Your phtml must be rendered by a block. The block must have a name in the layout.
You can do this after calling $this->loadLayout();
$block = Mage::app()->getLayout()->getBlock('block_name_here')
if ($block){//check if block actually exists
$block->setSomething($something);
}
Then you can get the value in the phtml
file like
$value = $this->getSomething();
//or
$value = $this->getData('something');
In case you people missed there is one more way to get this done
using sessions
Mage::getSingleton('core/session')->setSomeSessionVar($data);// In the Controller
$data = Mage::getSingleton('core/session')->getSomeSessionVar(); // In the View;
source