Shane A. Stillwell
Zend Framework Application Progress

Zend Framework Application Progress

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. The Times They Are A-Changin'

Today I learned from Zend Framework.

Redirecting visitors to their intended URI after login

LoginForm.php… // Grabs the requested URI from the server and stores it in a hidden field $this->addElement(‘hidden’, ‘referrer’, array(‘value’ => $_SERVER[‘REQUEST_URI’])); …

Then after you complete authentication, send them to the referring URIif($form->getValue(‘referrer’)) $this->_redirect($form->getValue(‘referrer’)); $this->_redirect(‘index/index’);

Credits: http://stackoverflow.com/questions/1249274/redirect-to-previous-page-in-zend-framework


Throwing an error message

This one is easy. You want to throw an error message with some meaning.throw new Zend_Exception(‘This is the error message’);


Saving data in Zend_Session

You want to save some data in a session variable so you can access it other places in application. So in the Bootstrap.php file you would placeZend_Session::start();

To set the variable you would use$ns = new Zend_Session_Namespace(‘hello’); $ns->domain = “Hello World”;By using the namespace “hello” or whatever you want, then you can keep your variables separate from another part of the applicate that just might happen to name it’s variable “domain” as well.

To retrieve this fun filled variable.$ns = new Zend_Session_Namespace(‘hello’); print $ns->domain;