Hi,
almost.
instead of:
> foreach ($namespaces as $namespace) {
> $messages = $this->getMessages($namespace);
use
foreach ($namespaces as $namespace) {
$this->setNamespace($namespace)
$messages = $this->getMessages();
Ludwig
Am 28.02.2013 16:14, schrieb Andrew Ballard:
> I thought I understood purpose of namespaces in the flash messenger,
> but now I'm not so sure. I thought that namespaces just created
> separate containers to which one or more messages could be written,
> but this does not seem to be the case.
>
> To test this, I put used this code in a controller action:
>
> $this->_helper->flashMessenger('Warning Message1', 'warning');
> $this->_helper->flashMessenger('Warning Message2', 'warning');
> $this->_helper->flashMessenger('Warning Message3', 'warning');
> $this->_helper->flashMessenger('Error Message1', 'error');
> $this->_helper->flashMessenger('Error Message2', 'error');
> $this->_helper->flashMessenger('Error Message3', 'error');
> $this->_helper->flashMessenger('Info Message1', 'info');
> $this->_helper->flashMessenger('Info Message2', 'info');
> $this->_helper->flashMessenger('Info Message3', 'info');
> $this->_helper->flashMessenger('Default Message1');
> $this->_helper->flashMessenger('Default Message2');
> $this->_helper->flashMessenger('Default Message3');
>
>
> Then I extended the flash messenger and registered my class in the
> bootstrap. That class has this method:
>
> public function postDispatch()
> {
>
> $view = $this->getActionController()->view;
>
> $namespaces = array('error', 'warning', 'info', null);
>
> $output = '';
>
> foreach ($namespaces as $namespace) {
> $messages = $this->getMessages($namespace);
> Zend_Debug::dump($messages, $namespace);
> if (count($messages)) {
> $output .= $view->htmlList($messages, false,
> array('class' => $namespace));
> }
> }
>
> $output = (strlen($output) === 0) ? '' : '<section
> class="messages">' . $output . '</section>';
>
> $view->layout()->messages = $output;
>
> }
>
> I expected the layout to output four blocks of message, each
> containing 3 messages, but this is only true of the non-namespaced
> messages. Here is the output I am getting:
>
> <section class="messages"><ul class="error">
> <li>Error Message3</li>
> </ul>
> <ul class="warning">
> <li>Warning Message3</li>
> </ul>
> <ul class="info">
> <li>Info Message3</li>
> </ul>
> <ul class="">
> <li>Default Message1</li>
> <li>Default Message2</li>
> <li>Default Message3</li>
> </ul>
> </section>
>
> Have I misunderstood the intent of these namespaces, or is something
> not working correctly?
>
> Andrew
>
--
Ludwig Ruderstaller
http://www.cwd.at
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]