$display_class = " class="".$flash_class. $display_class = " class="".$message_class.""" zend.assertions int When set to 1, assertion code will be generated and executed (development mode). This directive must be set in php.ini For example, you cannot set this in nf. It takes on a comma-delimited list of class names. Public function displayError($message, $message_class, $flash_message, $flash_class) This directive allows you to disable certain classes. Zend_Loader::loadClass("Zend_View_Helper_Abstract") Ĭlass Fp_View_Helper_DisplayError extends Zend_View_Helper_Abstract 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. $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. 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. 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: 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. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |