I'm using this library: http://code.google.com/p/data-registry/ with an ExpressionEngine system.
I initialize and set data in an EE plugin like this:
Data_Registry::init('MYPAGE');
Data_Registry::setPersistence(TRUE,TRUE)->restoreNameSpace();
Data_Registry::set('MYPAGE_DATA',json_encode($data['result']));
Data_Registry::set('MYPAGE_LOGGEDIN',true);
If I then log the values with this code, it shows the values correctly.
$fp = fopen('login_model.txt', 'a');
fwrite($fp, "Data:".Data_Registry::init('MYPAGE')->get('MYPAGE_DATA'). "\n");
fwrite($fp, "Loggedin:".Data_Registry::init('MYPAGE')->get('MYPAGE_LOGGEDIN'). "\n");
fclose($fp);
However, when trying to retrieve these values in a template using this code:
$data = Data_Registry::init('MYPAGE')->get('MYPAGE_DATA');
$loggedin = Data_Registry::init('MYPAGE')->get('MYPAGE_LOGGEDIN');
$fp = fopen('login_model.txt', 'a');
fwrite($fp, "Data:".$data . "\n");
fwrite($fp, "Loggedin:".$loggedin . "\n");
fclose($fp);
Both values are blank.
Am I doing something wrong here?
From Waygood's comment:
"If global persistence is enabled, all namespaces are loaded automaticly" so I assume you have to Data_Registry::setPersistence(TRUE,TRUE)->restoreNameSpace(); on the template to? unless you have set it as the default parameter