Question

i have an application form that is created on a CMS using this line

{{block type="[MODULE]/[BLOCK]" template="[TEMPLATE]"}}

now when you submit the form and get the success message at the top, it gets cached so no matter how many times i reload or return to the page from another page the success message remains

this is a problem because if you submit the form multiple times then go to the login page all the success messages all output there so they get piled up because their not outputting, and any error messages that should output because of invalidation do the same, the moment i clear the cache or turn it off it's fine

so how do i stop magento caching Global Messages on a CMS

Was it helpful?

Solution

If you are using a session model that extends the class Mage_Core_Model_Session_Abstract then you should be able to pass the value of true to the getMessages function. This will clone the messages ready to return them to be displayed to the user and then clear them from the session so they will only be displayed once.

public function getMessages($clear=false)
{
    if (!$this->getData('messages')) {
        $this->setMessages(Mage::getModel('core/message_collection'));
    }

    if ($clear) {
        $messages = clone $this->getData('messages');
        $this->getData('messages')->clear();
        Mage::dispatchEvent('core_session_abstract_clear_messages');
        return $messages;
    }
    return $this->getData('messages');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top