Bob O wrote:
> 
> Im trying to create a flash() that displays a message when the user needs
> to be notified of something. e.g. "incorrect login" etc...
> 

Bob,

   This is exactly what I do. I create a new Controller_Action like so

<?php
class App_Controller extends Zend_Controller_Action
{
        protected $_redirector;
        protected $_flashMessenger;

        public function init()
        {
                $this->_flashMessenger  = 
$this->_helper->getHelper('FlashMessenger');
                $this->_redirector = $this->_helper->getHelper('Redirector');
        }

        protected function flash($message,$to)
        {
                $this->_flashMessenger->addMessage($message);
                $this->_redirector->gotoUrl($to);
        }

        protected function setMessages()
        {
                $this->view->messages = 
join("",$this->_flashMessenger->getMessages());
        }
    public function postDispatch()
        {
                $this->setMessages();
                parent::postDispatch();
        }

}


Now all my controllers extend App_Controller. Which gives me access to 

$this->flash('Vehicle Added','/member/vehicle/view/id/'.$vid);

In my Layout.phtml 

<div class="leftFloat" id="columnRight">
                <?php if(count($this->messages) > 0){
                                        echo'<div align="center" 
class="flashmessage">';
                                        echo $this->messages;
                                        echo '</div>';
                        }
                        echo $this->layout()->content ?>     
</div>

Hope this helps

Eric Haskins
Web Applications Developer
-- 
View this message in context: 
http://www.nabble.com/FlashMessenger-tp21917164p21934715.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to