2017 © Pedro Peláez
 

library f3-flash

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

image

ikkez/f3-flash

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

  • Wednesday, December 6, 2017
  • by ikkez
  • Repository
  • 2 Watchers
  • 6 Stars
  • 1,116 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

Flash

This is a little plugin to add simple Flash Messages and Flash Keys for PHP Fat-Free-Framework, version 3.x, (*1)

Installation

  • Method 1: use composer composer require ikkez/f3-flash, (*2)

  • Method 2: copy the flash.php file into your F3 lib/ directory or another directory that is known to the AUTOLOADER, (*3)

Usage

To add a message (or multiple) that should only be displayed once in your template on the next request, just do:, (*4)

\Flash::instance()->addMessage('You did that wrong.', 'danger');
// or 
\Flash::instance()->addMessage('It worked!', 'success');

And to display that in your templates do:, (*5)

<!-- bootstrap style-->
<F3:repeat group="{{ \Flash::instance()->getMessages() }}" value="{{ @msg }}">
<div class="alert alert-{{ @msg.status }} alert-dismissable">
  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
  {{ @msg.text | esc }}
</div>
</F3:repeat>

That's it., (*6)

If you need, you could also add simple keys:, (*7)

$flash = \Flash::instance()
$f3->set('FLASH', $flash);
$flash->setKey('highlight','bg-success'); // with value
$flash->setKey('show-hint'); // without returns just TRUE
$flash->setKey('error','Catastrophic error occured! ');

for use cases like:, (*8)

<div class="box {{ @FLASH->getKey('highlight') }}">
  <F3:check if="{{ @FLASH->getKey('show-hint') }}">
  <p>It's new !!!</p>
  </F3:check>
  ...
</div>
<F3:check if="{{ @@FLASH && @FLASH->hasKey('error') }}">
    <p>{{ @FLASH->getKey('error') }}</p>
</F3:check>

License

You are allowed to use this plugin under the terms of the GNU General Public License version 3 or later., (*9)

Copyright (C) 2017 Christian Knuth [ikkez], (*10)

The Versions

06/12 2017

dev-master

9999999-dev https://github.com/ikkez/f3-middleware

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

  Sources   Download

GPL-3.0

The Requires

 

f3 session fatfree flash

17/02 2017

1.0.0

1.0.0.0 https://github.com/ikkez/f3-middleware

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

  Sources   Download

GPL-3.0

The Requires

 

f3 session fatfree flash