문제

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