This question already has an answer here:


<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

marked as duplicate by Murtuza Zabuawala, Raphael at Digital Pianism, Siarhey Uchukhlebau, Khoa TruongDinh, Amit Bera Jan 11 '17 at 18:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


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 .... – Sarvesh Tiwari Jan 11 '17 at 6:02
  • i used in phtml file <?php $data = Mage::getSingleton('core/session')->setEndBalance($data); echo $data; ?> – Sarvesh Tiwari Jan 11 '17 at 6:03
  • and in controller Mage::getSingleton('core/session')->setEndBalance($data); – Sarvesh Tiwari Jan 11 '17 at 6:03
  • In controller Mage::getSingleton('core/session')->setEndBalance($data); and in phtml <?php echo Mage::getSingleton('core/session')->getEndBalance(); ?> – Arunendra Jan 11 '17 at 6:05
  • i did not get solution – Sarvesh Tiwari Jan 11 '17 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 – Sarvesh Tiwari Jan 11 '17 at 6:13
  • get val in controller and add above code in controller – Prashant Valanda Jan 11 '17 at 6:29

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