I have a custom module, which uses for email varification in frontend
of magento. This module will appear as a popup in homepage while it loads. I want to do some other functionings such as display register form etc. in the same popup section, according to the output obtain from this email varification form...
Email varification happens in controller and it look like this
class Realuk_Login_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function loginAction()
{
$session = Mage::getSingleton('customer/session');
//check whether session exist or not
if ($session->isLoggedIn())
{
return;
}
$result=array('error'=>'noError','success'=>false);
/*
email varification code comes here; according to this section
$array will set;
*/
//json encoding happens here
$jsonData=$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); /
$this->_redirect('home'); //this is my home page redirection
}
}
my frontend file that render popup section contains this code..
<?php
$array = Mage::helper('core')->jsonDecode($jsonData);
if(!empty($array))
{
echo "<pre>";
print_r($array);
echo "</pre>";
}
else
{
echo "no json data exists";
}
?>
It seems that $array
is empty every time in frontend. However in controller $jsonData
posses some values. My url look likes www.mydomain.com/home/
and no json value can see there
My question is..
1)Is this the proper way to get results from controller to frontend?
2)How to accomplish json decoding in frontend phtml file ?
Please share your thoughts.. It will help me and others also.
Thanks in advance
$jsonData
with the JSON get to the popup on the homepage