Thats good enough then, thx. Regards, Saša Stamenković
On Mon, Dec 28, 2009 at 1:19 AM, Michael Depetrillo <[email protected]>wrote: > flashMessenger already has namespace support. > > > $this->getHelper('flashMessenger')->setNamespace("page1-errors")->addMessage($msg); > > $this->getHelper('flashMessenger')->setNamespace("page2-messages")->addMessage($msg2); > > I typically don't check if flash messenger has messages in controller. > > getMessages() will return an empty array() where there are no messages, > which is easy to work with in a view file. > > The third parameter of setExpirationHops($hops, $vars, > $hopCountOnUsageOnly) allows you to count a hop only when the specific > namespace (ie. 'page1-errors') is accessed. > > Michael DePetrillo > [email protected] > Mobile: (858) 761-1605 > www.michaeldepetrillo.com > > > On Fri, Dec 25, 2009 at 5:01 AM, umpirsky <[email protected]> wrote: > >> >> Something like >> >> http://jamandcheese-on-phptoast.com/2009/11/03/custom-flash-messenger-for-zend-framework/ >> can be handy. >> >> >> umpirsky wrote: >> > >> > Hi. >> > >> > I'm trying to use flashMessenger, but interface it provides is a bit >> > unhandy, because messages cannot be retreived by id, you can get only >> > array of messages and thats all. >> > >> > For example, I only need to detect success after sending email on my >> > contact page, and show some message to user if email is sent: >> > >> > class ContactController extends Zend_Controller_Action { >> > public function indexAction() { >> > $this->view->form = new Form_Contact(); >> > $this->view->sent = false; >> > if ($this->_helper->flashMessenger->hasMessages()) { >> > $this->view->sent = >> > array_pop($this->_helper->flashMessenger->getMessages()); >> > } >> > } >> > public function sendAction() { >> > $form = new Form_Contact(); >> > if ($form->isValid($_POST)) { >> > // TODO: send >> > $this->_helper->flashMessenger(true); >> > >> $this->_helper->redirector->gotoRoute(array('action' => 'index')); >> > } else { >> > $this->view->form = $form; >> > $this->render('index'); >> > } >> > } >> > } >> > >> > So, I pop here this flag (message) which is true if email is sent. >> > >> > This works, but, is there a simpler way to get flag I previously set? >> > And, I see that hops is set to 1 >> > self::$_session->setExpirationHops(1, null, true); >> > this means that if I get messages once, and use just one of them, all >> will >> > be deleted? >> > >> > Regards, >> > Saša Stamenković. >> > >> >> -- >> View this message in context: >> http://n4.nabble.com/flashMessenger-a-bit-hard-to-use-tp978447p978769.html >> >> Sent from the Zend Framework mailing list archive at Nabble.com. >> > >
