Why can't I get a message block in Magento to display on a category page?

I am trying to redirect Magento after the client clicks the "Add to Cart" button to the category page, which I did without problems (after a little search, of course), using a hidden field called "return_url". This part works fine, and the item is added to the cart, and the user is redirected back to the category page. Once here, no matter what I tried, I can not get the message block to display a success (or error) message. Here is my most recent code attempt (in view.phtml):

$messages=Mage::getSingleton("checkout/session")->getMessages();
echo $this->getLayout()->createBlock("core/messages")->setMessages($messages)->getGroupedHtml();

Thank!

+5
source share
1 answer

addSuccess/addError/addNotice?

Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('An error'));
Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__('A success'));
Mage::getSingleton('core/session')->addNotice(Mage::helper('core')->__('A notice'));
+3

All Articles