View Single Post
  #3 (permalink)  
Old 06-20-2008, 08:32 PM
jweber jweber is offline
Senior Member
 
Join Date: Jun 2008
Location: Florida
Posts: 108
Default

The scope of the namespace as you are creating it is the same as any other variable. If you want to make the namespace available elsewhere you need to instantiate the Zend_Session_Namespace class everywhere that you want it available, or store it in a variable whose scope is accessible to each class/script that you want to have access to it.

For exmaple, you could place it in a view variable one time in your controller:
Code:
$this->view->exampleNamespace = new Zend_Session_Namespace('example');

$this->view->exampleNamespace = 'hello world';
Then throughout your controller calling this:
Code:
echo $this->view->exampleNamespace;
Will result in:
Code:
hello world
To access this same variable in your view you simply refer to it as $this->exampleNamespace.

If you wanted to narrow the scope a bit you could create a private class variable in your controller. Then any method in that controller class would of course have access to any value in that variable.
Reply With Quote