Zend framework Flash message.
The FlashMessenger helper is used to render the messages of the FlashMessenger.
It will find in Zend/View/Helper/FlashMessenger.php
A) Module Config Stuff
In module.config.php, Module wise( if you have Product module, Album module)
module\product\config\module.config.php
You need to put following code module wise.
'view_helper_config' => array(
'flashmessenger' => array(
'message_open_format' => '<div%s><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><ul><li>',
'message_close_string' => '</li></ul></div>',
'message_separator_string' => '</li><li>'
)
),
C) Controller Stuff
Now in ProductController.php (Product is assuming, depends upon your controller name where you want to put)
1) For success message (Green Colour)
$this->flashMessenger()->addSuccessMessage('Product has been saved successfully.');
2) For warning message (light Red Colour)
$this->flashMessenger()->addWarningMessage('Warning has been issued.');
3) For error message (Red Colour)
$this->flashMessenger()->addErrorMessage('An error has been occurred.');
4) For info message (Yellowish Colour)
$this->flashMessenger()->addInfoMessage('An info message has been generated.');
C) Finally on View page
Put this code in layout.phtml. layout.phtml file will find in module\Application\view\layout\layout.phtml
<?php
$flash = $this->flashMessenger();
$flash->setMessageOpenFormat('<div%s><button type="button" class="close" data-dismiss="alert" aria-hidden="true">× </button><ul><li>')
->setMessageSeparatorString('</li><li>')
->setMessageCloseString('</li></ul></div>');
echo $flash->render('error', array('alert', 'alert-dismissible', 'alert-danger'));
echo $flash->render('info', array('alert', 'alert-dismissible', 'alert-info'));
echo $flash->render('default', array('alert', 'alert-dismissible', 'alert-warning'));
echo $flash->render('success', array('alert', 'alert-dismissible', 'alert-success'));
?>
For more detail please go through following link
References:
Reference Zend Framework
No comments:
Post a Comment