Wallogit.com
2017 © Pedro Peláez
Class to show flash messages
, (*1)
Module for session-based Flash Messages that handels messages for error, success and information. If you are using Anax/MVC use the class CMessageAnax., (*2)
This software is free software and carries a MIT license., (*3)
Session must be started before including CMessage., (*4)
Include CMessage by adding this lines:, (*5)
$di->set('message', function() {
$message = new \Isa\CMessage\CMessage();
return $message;
});
If you are using Anax/MVC include CMessage with this lines:, (*6)
$di->set('message', function() use ($di) {
$message = new \Isa\CMessage\CMessageAnax($di);
return $message;
});
Simply add the desired messages by adding these lines:, (*7)
For error-messages:, (*8)
$app->message->addErrorMessage('This is a error-message');
For success-messages:, (*9)
$app->message->addSuccessMessage('This is a success-message');
For information-messages:, (*10)
This lines will save the message/messages in the session and when you want to print out the messages call the method printMessage:, (*11)
$app->message->printMessage();
For example you could place the messages in a variable like this:, (*12)
$messages = $app->message->printMessage();
and then use this line to print it out on a page:, (*13)
$app->views->addString($messages);
The messages are using icons from Font Awesome. If you want to include icons in your messages just download Font Awesome from http://fortawesome.github.io/Font-Awesome/ and place it in your project. Then make the project use the css-file, for example like this:, (*14)
$app->theme->addStylesheet('css/font-awesome/css/font-awesome.css');
If you dont want to use the icons the messages will look fine even without them., (*15)