Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2008, 12:29 AM
Junior Member
 
Join Date: Mar 2008
Posts: 15
Default How do I access flashMessenger message after redirect

I was playing around with ZF, and stuck here, really appreciate if anyone can help

For example, I have this action in one of my controllers

PHP Code:
    public function indexAction() {
        
$this->_helper->flashMessenger->addMessage("Test Here.");
        
$this->_redirect('/');
    } 
And in my /index/index.phtml, how should I get the message after this redirection, thanks.

Last edited by iroy2000 : 03-08-2008 at 12:31 AM. Reason: add space
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-10-2008, 04:03 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

PHP Code:
$this->_flashMessenger->getMessages(); 
This will get the messages set to the flashMessenger helper.

More info: Zend Framework: Documentation (Look for this section: 7.8.4.4. FlashMessenger)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-10-2008, 09:56 PM
Junior Member
 
Join Date: Mar 2008
Posts: 15
Default

Thanks for your reply, but when I tried to do this in my index/index.phtml

PHP Code:
    print_r($this->_flashMessenger->getMessages()); 
and tried

PHP Code:
    print_r($this->flashMessenger->getMessages()); 
Both gave me the same error....

Fatal error: Call to a member function getMessages() on a non-object

Last edited by iroy2000 : 03-10-2008 at 10:01 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-11-2008, 06:03 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

you need to instanstiate your object.

Try this in your action method:

PHP Code:
        $this->_flashMessenger $this->_helper->getHelper('FlashMessenger');
        
$this->view->messages $this->_flashMessenger->getMessages(); 
Then use this in your view:
PHP Code:
        print_r($this->messages); 
__________________
- xentek
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-29-2008, 07:40 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default How to clear flashMessenger Messages

Hi,

I apologize in advance for this simplicity of this questions or if it has already been addressed... so once the a message as been retrieved with $this->_flashMessenger->getMessages(), does it automatically get wiped or is there a method I that I need to call to do this manually?

Thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-29-2008, 08:48 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default Follow Up:

Never mind everyone.... answered my own questions.

According to the documentation:

"A subsequent request to the action /some/my-next-request will retrieve it (and thus delete it as well)."

Thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:05 AM.