Git Product home page Git Product logo

notices's Introduction

Notices for Zend Framework 2/3

Extension for displaying messages in Zend Framework 2/3 and Twitter bootstrap 3 applications.

Installation

Use Composer:

$ composer require ilyaserdyuk/notices:^1.0

And add to layout:

<?= $this->notices() ?>

How use

Send messages from the controllers:

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $this->notices()->addSuccessMessage('You successfully read this important alert message.');
        $this->notices()->addInfoMessage('This alert needs your attention, but it\'s not super important.');
        $this->notices()->addWarningMessage('Better check yourself, you\'re not looking too good.');
        $this->notices()->addErrorMessage('Change a few things up and try submitting again.');
    }
}

Output:

<div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
    <strong>Well done!</strong>
    You successfully read this important alert message.
</div>

<div class="alert alert-info alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
    <strong>Heads up!</strong>
    This alert needs your attention, but it's not super important.
</div>

<div class="alert alert-warning alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
    <strong>Warning!</strong>
    Better check yourself, you're not looking too good.
</div>

<div class="alert alert-danger alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
    <strong>Oh snap!</strong>
    Change a few things up and try submitting again.
</div>

How to configure

You can customize the output template, turn off escaping and change the label of messages. To do this, add to config file (config/autoload/global.php):

return [
    'view_helper_config' => [
        'notices' => [
            'auto_escape' => true,
            'template_string' => '<div class="alert alert-{class} alert-dismissible" role="alert">{text}</div>',
            'label_for_status' => [
                Message::CLASS_SUCCESS => 'Успешно:',
                Message::CLASS_INFO => 'Информация:',
                Message::CLASS_WARNING => 'Предупреждение:',
                Message::CLASS_ERROR => 'Ошибка:',
            ],
        ],
    ],
];

notices's People

Contributors

ilyaserdyuk avatar stepdi avatar

Watchers

James Cloos avatar  avatar

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.