Magento add notification, success, and error messages

Assume you have a controller that uses the app/design/frontend/base/default/template/page/1column.phtml layout. You can add success or error notification messages in the controller action function like these

	Mage::getSingleton("core/session")->addNotice("Some notification message");
	Mage::getSingleton("core/session")->addSuccess("Some action success message"); 
	Mage::getSingleton("core/session")->addError("Some error message"); 

If you open up the 1column.phtml or 2columns-left.phtml or 2columns-right.phtml or 3columns.phtml, you will find these messages are being included by this line of code.

 <?php echo $this->getChildHtml('global_messages'); ?>

If you open up the app/design/frontend/base/default/layout/page.xml, you will find that the template global_messages is defined by this line of xml code.

<block type="core/messages" name="global_messages" as="global_messages"/>

Search within Codexpedia

Custom Search

Search the entire web

Custom Search