<input  type="text"  class="input-text required-entry validate-number form-control validate-zero-or-greater" id= "checkout-cart-credit-amount-textboxone"  title="<?php echo $this->__('Gift Card Credit') ?>" name="customer_creditone" />


public function getTextValueAction ()
    $input_amount = $this->getRequest()->getParam('customer_creditone');
    //echo $input_amount.'<br>';


controller is working fine me. how to call controller variable to phtml file


3 Answers 3


you can pass variable from controller like

$this->getLayout()->getBlock('block.name')->assign('somestring', $variable)

and in phtml you can simply use like

<?php echo $variable ?>


You can do it by Mage registry :

Mage::register('custom_value', $monthly_budget);

and then get it in phtml :

$monthly_budget = Mage::registry('custom_value');

Another way using session :

In controller set value:


In phtml get Value:

$data = Mage::getSingleton('core/session')->getYourDataVal(); 
  • i did not get solution .... Commented Jan 11, 2017 at 6:02
  • i used in phtml file <?php $data = Mage::getSingleton('core/session')->setEndBalance($data); echo $data; ?> Commented Jan 11, 2017 at 6:03
  • and in controller Mage::getSingleton('core/session')->setEndBalance($data); Commented Jan 11, 2017 at 6:03
  • In controller Mage::getSingleton('core/session')->setEndBalance($data); and in phtml <?php echo Mage::getSingleton('core/session')->getEndBalance(); ?>
    – Arunendra
    Commented Jan 11, 2017 at 6:05
  • i did not get solution Commented Jan 11, 2017 at 6:12

You can set variable to block and use that block to phtml file and get attribute value

Use below code in controller file:


Use below code in template file:

echo $this->getLayout()->createBlock("modulename/blockname")->getYourattribute();
  • i am using attribute bro ....i have fetched value from input box now i want to call it on phtml file Commented Jan 11, 2017 at 6:13
  • get val in controller and add above code in controller Commented Jan 11, 2017 at 6:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.