Wallogit.com
2017 © Pedro Peláez
Class for flash messages
Flash messages, a class to show sucess, info, warning and error messages for the user., (*2)
By Alex Chau, alex_chau6@hotmail.com, (*3)
First of all install by using composer. Add this code to your composer.json:, (*4)
"require": {
"erogami/cfmessage": "dev-master"
},
Add this code to your front-controller., (*5)
$di->set('Cfmessage', function() use ($di) {
$message = new \erogami\Cfmessage\Cfmessage($di);
return $message;
});
Now add these lines to get your message., (*6)
For info messages:, (*7)
$app->Cfmessage->addInfo('This is an information message');
For error messages:, (*8)
$app->Cfmessage->addError('This is an error message');
For warning messages:, (*9)
$app->Cfmessage->addWarning('This is a warning message');
For success messages:, (*10)
$app->Cfmessage->addSuccess('This is a success message');
The messages will be saved in the session, call these lines to print out the messages:, (*11)
$messages = $app->Cfmessage->printMessage();
$app->views->addString($messages);
The class uses Font Awesome, but works without it too. So it's optional wheter you want to include the icons or not., (*12)