Skip to content

Instantly share code, notes, and snippets.

@mathewjosephh
Last active June 10, 2016 11:53
Show Gist options
  • Save mathewjosephh/66680c5b1d22bb096507c8b61dacb0fd to your computer and use it in GitHub Desktop.
Save mathewjosephh/66680c5b1d22bb096507c8b61dacb0fd to your computer and use it in GitHub Desktop.
Pass data from controller to view in magento
<?php $blas = Mage::getSingleton('Modulename/viewinfo'); ?>
<?php echo $blas->getMsg(); ?>
public function indexAction()
{
$bla = Mage::getSingleton('Modulename/viewinfo');
$bla->setMsg("Thank You for your visit!");
$this->loadLayout();
$this->renderLayout();
}
Packname_Modulename_Model_Viewinfo extends Varien_Object{
//It’s may be very easy for Zend framework user But, I find some magento developer fighting to pass data from controller to view.
//In magento you have to create a empty model(if your mod don’t have a varient object model) which extends to varient object. Magento use magic getter magic setter so you can pass value by setAnyname() and getAnyname() thus functions will be auto defines by Zend like many other framework do
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment