-
Notifications
You must be signed in to change notification settings - Fork 12
OSS_Message
Barry O'Donovan edited this page Nov 19, 2012
·
1 revision
OSS_Message is a library allowing you to place success / error / alert / informational messages on a webpage after a successful operation (whether through direct response or redirection).
In your controller, ensure you use the OSS_Message
and the other required traits:
use OSS_Controller_Action_Trait_Namespace;
use OSS_Controller_Action_Trait_Smarty;
use OSS_Controller_Action_Trait_Messages;
On any page where you may need a message displayed, put the following Smarty tag at the appropriate position (for example towards the top of your page below any headers and menus):
{OSS_Message}
This template function will display any (and all) messages that have been added to the response. You add a message to the response as follows:
$this->addMessage( 'Congratulations, this is a success message!', OSS_Message::SUCCESS, OSS_Message::TYPE_MESSAGE );
The available alerts are:
-
OSS_Message::SUCCESS
(green) -
OSS_Message::INFO
(blue) -
OSS_Message::WARNING
(orange) -
OSS_Message::ERROR
(red)
And the available types are:
-
OSS_Message::TYPE_MESSAGE
- standard message (see Bootstrap example) -
OSS_Message::TYPE_BLOCK
- longer message (see Bootstrap.alert-block
example) -
OSS_Message::TYPE_POP_UP
- a pop up message box via Bootbox.js
$this->addMessage( '<h4>Congratulations!</h4>, This is a success message!', OSS_Message::SUCCESS, OSS_Message::TYPE_BLOCK );
$this->addMessage(
'<strong>Congratulations and welcome to our site.</strong><br /><br />'
. 'Your account has been created but you must first confirm your email address.<br /><br />'
. 'You have been sent a welcome email with instructions on how to do this.',
null, OSS_Message::TYPE_POP_UP
);