I am new in magento. I facing a problem that i want to pass my values from my controller to my view page. But I don't know the syntax. Please anybody help me.
This is my controller: –
<?php
class Test_Mymodule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function calculateAction()
{
$request = $this->getRequest();
if($this->getRequest()->isPost())
{
$printdata = $request->getPost();
}
else
{
}
$helloworld = Mage::getModel("test_mymodule/results");
$helloworld->helloworld("helloworld");
}
}
I want to display the value of $helloworld to my view name "calculate".
Best Answer
Magento uses magic get and set methods so in perfect magento world you would have controller -> block (extending mage_core_block_template ) -> view (template is either set from block instance or from layout) and then you could use the set and get methods from $this context
in controller:
in template and block instance:
however from your code example you should have a method "helloworld" in your model (object) that would accept a single parameter (that you have set to be string "helloworld" in your example)
if you have defined your layout rules in xml for your controller layout handler then you can get the defined blocks directly from layout and you can skip the generation syntax: