- Frank Mullenger My Blog
- SilverStripe 2.4
To store a message with an attached status in the session and 'flash' that message in the browser. Based on code from Will Rossiter
- Place this directory in the root of your SilverStripe installation, rename the folder 'statusmessage'.
- Visit yoursite.com/dev/build?flush=1 to rebuild the database.
###Session
- Set a status message in a controller or similar e.g:
StatusMessage::set(StatusMessage::STATUS_SUCCESS, "Here is some message");
- Get a status message out of the session in a template e.g:
<% include StatusMessage %>
###URL
When redirecting have to pass the status message in the URL rather than the Session.
- Set the message as above.
- Append the status message to the GET string e.g: Director::redirect(Director::absoluteBaseURL() . $this->Link() . '?' . StatusMessage::query_string());