ruturajmaniyar/yii2-flash-toastr Toastr flash notification using jQuery with yii2

ruturajmaniyar/yii2-flash-toastr

  1. Current Version
  2. Installation
  3. Usage
  4. Other Options

Toastr flash notification using jQuery with yii2

GitHub release Packagist

Current Version

v1.0 @stable @pre-release

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ruturajmaniyar/yii2-flash-toastr: "dev-master"

or

composer require --prefer-dist ruturajmaniyar/yii2-flash-toastr: "dev-master"

or add

"ruturajmaniyar/yii2-flash-toastr": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php if (Yii::$app->session->hasFlash('success')): ?>
    <?= ToastrFlashMessage::widget([
        'type' => 'success',
        'title' => 'Success',
        'message' => Yii::$app->session->getFlash('success')
    ]); ?>
<?php endif; ?>

<?php if (Yii::$app->session->hasFlash('error')): ?>
    <?= ToastrFlashMessage::widget([
        'type' => 'error',
        'title' => 'Error',
        'message' => Yii::$app->session->getFlash('error')
    ]); ?>
<?php endif; ?>

You can also use with below code

<?= ToastrFlashMessageSession::widget() ?>

With above code, extension set toastr message dynamically based on your flash session message

Other Options

'options' => [
        "closeButton" => true,
        "newestOnTop" => true,
        "progressBar" => true,
        "positionClass" => ToastrFlashMessage::POSITION_TOP_RIGHT,
        "showDuration" => "300", 
        "hideDuration" => "1000",
        "timeOut" => "5000",
        "extendedTimeOut" => "1000",
        "showEasing" => "swing",
        "hideEasing" => "linear",
        "closeEasing" => "linear",
        "showMethod" => "slideDown",
        "hideMethod" => "slideUp",
        "closeMethod" => "slideUp"
    ]
Toast Position Options:
POSITION_TOP_RIGHT = 'toast-top-right';
POSITION_TOP_LEFT = 'toast-top-left';
POSITION_TOP_CENTER = 'toast-top-center';
POSITION_TOP_FULL_WIDTH = 'toast-top-full-width';

POSITION_BOTTOM_RIGHT = 'toast-bottom-right';
POSITION_BOTTOM_LEFT = 'toast-bottom-left';
POSITION_BOTTOM_CENTER = 'toast-bottom-center';
POSITION_BOTTOM_FULL_WIDTH = 'toast-bottom-full-width';
DEMO
1 0
1 follower
3 318 downloads
Yii Version: 2.0
License: BSD-3-Clause
Category: User Interface
Developed by: Ruturaj Maniyar
Created on: Jun 12, 2019
Last updated: 5 years ago
Packagist Profile
Github Repository

Related Extensions