1

form

<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" />

controller

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

    $this->_redirect('checkout/cart');
    }

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

7

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 ?>

5

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:

Mage::getSingleton('core/session')->setYourDataVal($data);

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
3

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

Use below code in controller file:

$this->getLayout()->createBlock("modulename/blockname")->setYourattribute($value);

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.