forfreegift.blogg.se

Zend redirector
Zend redirector








$display_class = " class="".$flash_class. $display_class = " class="".$message_class.""" Public function displayError($message, $message_class, $flash_message, $flash_class) Zend_Loader::loadClass("Zend_View_Helper_Abstract") Ĭlass Fp_View_Helper_DisplayError extends Zend_View_Helper_Abstract Check your uploads folder to make sure it has no php or js files prior to uploading it back. I would also delete users table and not import it, leaving the new one in place. If I create the message when I'm going to redirect them I use session, if it's created in the controller just before the action is called I use a local variable within the view object. Delete all the tables in the database pertaining to Zend plugin prior to importing it back. $this->displayError($this->message, $this->message_class, $_SESSION, $_SESSION) Īs you can see I pass it a local variable and a session value. I style the message differently depending on the type. In my instance I like to tell it what type of message I'm passing it, a confirmation or an error. I know this probably isn't the best way to do it, but I wrote this before the flash message helper was in place. This will create an array of messages in your view object which you can then loop over in your view script:Īnd that’s all there is to the FlashMessenger. $this->view->messages = $this->_helper->flashMessenger->getMessages() Retrieving the stored messages is similarly simple: This is very useful and it means that if someone refreshes the task list by hitting F5, then the “Task saved” message does not reappear. This means that the message will be available for retrieval on the next request, but unavailable on the request afterwards.

zend redirector

The FlashMessenger will store the message that you’ve added for one hop, or number of requests. As should be obvious from the name of the method, you can add multiple messages and they will all be stored for retrieval after the next redirect.

Zend redirector code#

This code adds the message “Task saved” to the FlashMessenger and then redirects the user the index action, which in this case is a list of tasks. $this->_helper->flashMessenger->addMessage('Task saved') This is my typical usage within an action controller:

zend redirector

The most common use I have for it is for a “saved” message after doing an edit of an item that then redirects back to a list.

zend redirector

I’ve talked about Zend Framework’s action helpers before, but haven’t covered any of the action helpers that are supplied with Zend Framework.įlashMessenger is a helper that allows you to store messages between requests.








Zend redirector