2017 © Pedro PelĂĄez
 

library flash

Small flash class for Anax-MVC

image

itzy/flash

Small flash class for Anax-MVC

  • Friday, May 16, 2014
  • by itzy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Flash by itzy

badge Scrutinizer Code Quality Code Coverage, (*1)

A flash module for Anax-MVC, created by Julia Sivartsson, webdeveloper-student at Blekinge Tekniska Högskola. This module comes with a simple stylesheet and icons that are available if you have Font Awesome (information further down)., (*2)

It comes with four diffent styles: - information - success - warning - error, (*3)

Preview

flash example, (*4)

How to use in Anax-MVC

First of all you need to implement CFlash in your own Anax-MVC version, simply place the class in your 'src'-folder. At the top of your frontcontroller, add the following:, (*5)

// Get environment & autoloader and the $app-object.
require __DIR__.'/config_with_app.php';

// Get the class CFlash
$di->setShared('flash', function() {
$flash = new Anax\Flash\CFlash();
return $flash;
});

// Starts the session, wich is required by Flash by itzy
$app->session;

If you want to use the stylesheet that comes with the module, put flash.css in your css folder to make it work, then write the following code in your froncontroller (below the previous code):, (*6)

// Add stylesheet for flash by itzy
$app->theme->addStylesheet('css/flash.css');

That's it! Now you can get flash by itzy for your own website., (*7)

// Put this in a route in your frontcontroller
$app->flash->add('info', 'Better be on your toes, this needs your attention but is not urgent.');
$app->flash->add('success', 'Yay! You are totally successful !');
$app->flash->add('warning', 'Dude, I have to warn you, you do not look too good.');
$app->flash->add('error', 'Oh snap, something went wrong!');

//If you're in a controller
$this->flash->add('info', 'Better be on your toes, this needs your attention but is not urgent.');
$this->flash->add('success', 'Yay! You are totally successful !');
$this->flash->add('warning', 'Dude, I have to warn you, you do not look too good.');
$this->flash->add('error', 'Oh snap, something went wrong!');

To then make the messages visible, add the following code inside your route/controller:, (*8)

    //frontcontroller
    $app->flash->get();

    //controller or view
    $this->flash->get();

If you have support for Font Awesome, wich you get very easy from their page (http://fortawesome.github.io/Font-Awesome/) change the code to this:, (*9)

    //frontcontroller
    $app->flash->get('icons');

    //controller or view
    $this->flash->get('icons');

Not that hard, right! If you look at the code of your website it will look similar to this:, (*10)

<div class='flash_info'>
<i class='fa fa-info-circle'></i>
Better be on your toes, this needs your attention but is not urgent.
</div>

<div class='flash_success'>
<i class='fa fa-check'></i>
Yay! You are totally successful !
</div>

<div class='flash_warning'>
<i class='fa fa-warning'></i>
Dude, I have to warn you, you do not look too good.
</div>

<div class='flash_error'>
<i class='fa fa-times-circle'></i>
Oh snap, something went wrong!
</div>

Have fun! © Julia Sivartsson, (*11)

The Versions

16/05 2014

dev-master

9999999-dev https://github.com/itzy

Small flash class for Anax-MVC

  Sources   Download

MIT

The Requires

  • php >=5.4

 

mvc anax flash itzy