dev-master
9999999-dev https://github.com/tijo15/flashmessagesFlashmessage module for anax mvc
MIT
The Requires
- php >=5.4
- anax/mvc dev-master
by Tim J-H
flashmessages
Flashmessage module for anax mvc
School project to create a module for the Anax MVC framework., (*2)
Flash Messages lets you add flash messages to the Anax mvc. There are 4 different messages which has a css design to them: Approved, Information, Error and Warning., (*3)
You can easily add your own messages but you have to specify the design for them in the flash.css file., (*4)
How to install, (*5)
To install, use composer and add this line: "require": {"tijo15/flash-message": "dev-master" }, (*6)
To access the controller use this in your frontcontroller:, (*7)
// Include the essential settings., (*8)
require DIR.'/config.php';, (*9)
// Create services and inject into the app., (*10)
$di = new \Anax\DI\CDIFactoryDefault();, (*11)
// Adds the Flash controller, (*12)
$di->setShared('flashMessages', function() use ($di){ $flashMessages = new tijo15\FlashMessage\FlashController($di); return $flashMessages; });, (*13)
How to use, (*14)
Add the route in your front controller:, (*15)
// Test Route $app->router->add('', function() use ($app) {, (*16)
$app->theme->setTitle("Testing flash"); //Code to test each message, including a default message(Test). $app->flashMessages->addMessage('Godkänt!', 'success'); $app->flashMessages->addMessage('Information', 'info'); $app->flashMessages->addMessage('Varning!', 'warning'); $app->flashMessages->addMessage('Error', 'error'); $app->flashMessages->addMessage('Test', 'Test'); //Adds the view to display the messages $app->views->add('flash/flash', [ 'content' => $app->flashMessages->getFlashMessages(), ]);
});, (*17)
If you want to add a new message you need to add a background color to flash.css like this, (*18)
.newmsg { background-color:#f0cb11; }, (*19)
Make sure that the name in the css corresponds to the name in the addMessage function like this: $app->flashMessages->addMessage('Test new msg', 'newmsg');, (*20)
Flashmessage module for anax mvc
MIT
flashmessages