1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.controller.actionhelpers.flashmessenger">
4 <title>FlashMessenger</title>
6 <sect4 id="zend.controller.actionhelper.flashmessenger.introduction">
7 <title>Introduction</title>
10 The <emphasis>FlashMessenger</emphasis> helper allows you to pass messages
11 that the user may need to see on the next request. To accomplish
12 this, <emphasis>FlashMessenger</emphasis> uses
13 <classname>Zend_Session_Namespace</classname> to store messages for future or
14 next request retrieval. It is generally a good idea that if you
15 plan on using <classname>Zend_Session</classname> or
16 <classname>Zend_Session_Namespace</classname>, that you initialize with
17 <methodname>Zend_Session::start()</methodname> in your bootstrap file. (See the
18 <link linkend="zend.session.advanced_usage.starting_a_session">Zend_Session</link>
19 documentation for more details on its usage.)
23 <sect4 id="zend.controller.actionhelper.flashmessenger.basicusage">
24 <title>Basic Usage Example</title>
27 The usage example below shows the use of the flash messenger at its
28 most basic. When the action <filename>/some/my</filename> is called, it adds
29 the flash message "Record Saved!" A subsequent request to the action
30 <filename>/some/my-next-request</filename> will retrieve it (and thus delete
34 <programlisting language="php"><![CDATA[
35 class SomeController extends Zend_Controller_Action
40 * @var Zend_Controller_Action_Helper_FlashMessenger
42 protected $_flashMessenger = null;
44 public function init()
46 $this->_flashMessenger =
47 $this->_helper->getHelper('FlashMessenger');
51 public function myAction()
54 * default method of getting
55 * Zend_Controller_Action_Helper_FlashMessenger instance
58 $this->_flashMessenger->addMessage('Record Saved!');
61 public function myNextRequestAction()
63 $this->view->messages = $this->_flashMessenger->getMessages();