Magento notification messages
when ever we create custom extention we need to show some user defined flash messages
this article help you, how messasing system works in magento and how we can use it for our custom work
Default Magento installation has a bunch of notification messages that get outputted to the browser
It is something every theme and/or extension developer should know about. This notification system uses exactly four different message types. These are: notice, success, error, warning.
Messages are stored on a session model.
Each of these session models is capable of accepting those four types of messages by method call like shown on the example below.
Mage::getSingleton('core/session')->addError('Error Message’); Mage::getSingleton('core/session')->addWarning('Warning Message'); Mage::getSingleton('core/session')->addNotice('Notice Message'); Mage::getSingleton('core/session')->addSuccess('Success Message');
Once you add a message to the session model, it will get rendered on the front-end on the next page that gets loaded.
Notice how warning messages are not styled at all, so you might want to give it a slight touch of styling if you are doing a custom theme development, just in case someone decides to throw something in them. Below is an example of HTML that gets outputted in browser for the messages.
<li><span>Error Message Here</span></li>
<li><span>Warning Message Here</span></li>
<li><span>Notice Message Here</span></li>
<li><span>Success Message Here</span></li>
Once the messages are rendered, they are cleared from session model. This is important to keep in mind, as it tells you basically that it makes no sense to do a message adding within theme (.phtml) files.
Proper way is to add messages through your controller actions, or even block and model classes. You can do a quick search for string “session’)->add” across entire Magento, this will give you a list of all notification messages Magento uses.
The order at which these messages appear on the store frontend and entire HTML output are defined in Mage_Core_Block_Messages class within getGroupedHtml() method, so there is no theme .phtml file you can edit to change the sort order.
This should give you enough insight in order to stay on top with Magento notification messages.