Having written the Noumenal FlashMessenger View Helper I should be able to help. :-)
To answer your question:
Adding Messages
You can set different message levels, e.g. error
, warning
etc, by passing an array to the FlashMessenger Action Helper rather than a simple string:
// ExampleController.php
$this->_helper->FlashMessenger(
array('error'=>'Sorry, could not complete your request.')
);
The view helper is designed to recognise this.
Outputting Messages
When outputting FlashMessages in your layout, there are optional parameters that you can pass to specify the default message level (which is warning
by default) and a template for your message.
Adapting your code snippet to account for differing message levels you could achieve the desired result by making the following call in your layout:
// layout.phtml
$template = '<div class="ui-state-error ui-corner-all">
<p class="%s"><span class="ui-icon ui-icon-alert"></span>
<span class="flash-message">%s</span></p>
</div>';
echo $this->flashMessenger('error', $template);
(You may find it better to set the template as a view variable in, say, your bootstrap.)
Doing this the view helper will construct the appropriately formatted flash messages for you as you wish.
Some Simple Styling
Using CSS there would be plenty of room to style the messages appropriately. For example:
.alert {
color: red;
}
.alert .flash-message:before {
content: "<strong>Alert</strong> ";
}
.notice {
color:yellow;
}
.notice .flash-message:before {
content: "<strong>Notice</strong> ";
}
I leave you to improvise...
I wrote a guide to Zend Framework FlashMessenger and the view helper on my blog. Perhaps give that a read. Also please do email me to let me know your difficulties -- it will help me know what I need to improve.
I hope that helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…