Git Product home page Git Product logo

li3_flash_message's Introduction

Flash Message Plugin for Lithium

The Flash Message (li3_flash_message) plugin provides a straightforward interface for displaying status messages to the user.

Goals

  • Use existing session storage
  • Eliminate message content from controllers
  • Easily localize messages
  • Use filters to integrate into existing workflow

Integration

<?php

// config/bootstrap/libraries.php:

Libraries::add('li3_flash_message');

?>

Usage

Here is an example of adding flash messages in a controller:

<?php
namespace app\controllers;

use lithium\security\Auth;
use li3_flash_message\extensions\storage\FlashMessage;

class AdministratorsController extends \lithium\action\Controller {
    public function login() {
        if (Auth::check('admin', $this->request)) {
            FlashMessage::write('Logged you in!');
            return $this->redirect(array('Employees::index'));
        }

        $loginFailed = false;
        if ($this->request->data){
            $loginFailed = true;
        }
        return compact('loginFailed');
    }

    public function logout() {
        FlashMessage::write('Logged you out!');
        Auth::clear('admin');
        return $this->redirect('/');
    }
}
?>

To include the messages in your template, simply add:

<?= $this->flashMessage->show() ?>

By default, libraries/li3_flash_message/app/views/elements/flash_message.html.php will be used to render your flash message. You can create app/views/elements/flash_message.html.php to override it and render it however you like!

For a full example of using this library, please see the relevant chapter in "Step by step Li3".

li3_flash_message's People

Contributors

michaelhue avatar nateabele avatar

Stargazers

Josh avatar Gavin Davies avatar

Watchers

Gavin Davies avatar James Cloos avatar

Forkers

ppadron

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.