I have stored a variable in register by Mage::register('captcha', $var); in helper. And in the controller i tried to retrieve the variable by using Mage::registry('captcha'); But i dont getting any values here. Please help me to solve this.

有帮助吗?

解决方案

In your helper file create a function like below :

public function getCaptcha(){
    $var = 'myValue123';
    Mage::register('varun', $var);
    return Mage::registry('varun');
}

In your controller function:

$registryValue = Mage::helper('yourModule')->getCaptcha();
echo registryValue ; //prints myValue123

Hope it helps !!!

其他提示

It's look like syntax is right. Please first try to set some static value like $var="test"

Mage::register('captcha', $var);

after that got this value in controller.

Mage::registry('captcha');

if you got this value test then i think you have problem with $var in your helper.

Let me know if you have any problem

'captcha' is already in use, so magento never set your data in registry. Change the name, for example 'captcha1'

Mage::register('captcha1', $var);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top