This Messages package work like a flash message containers, and it's copied from fuel-depot ( https://github.com/fuel/depot/blob/1.0/develop/fuel/app/classes/messages.php ) for package it.
- Clone or download this repository
- Move it in fuel/packages/
- Add 'messages' to the 'always_load/packages' array in app/config/config.php (or call \Package::load('messages'); whenever you want to use it).
In your controller for example :
// Add success message
\Messages::success('Registration done!');
// Add warning message
\Messages::warning('You must specify your name!');
// Add error message
\Messages::error('An error has occured!');
// Add info message
\Messages::info('Hello!');
In your view :
<?php if (\Messages::any()): ?>
<br/>
<?php foreach (array('success', 'info', 'warning', 'error') as $type): ?>
<?php foreach (\Messages::instance()->get($type) as $message): ?>
<div class="alert alert-<?= $message['type']; ?>"><?= $message['body']; ?></div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php \Messages::reset(); ?>
<?php endif; ?>
This package contains a Twig extension, if you want to install it, read the readme.