diecoding/yii2-toastr Simple flash toastr notifications for Yii2

Yii2 Toastr

  1. Table of Contents
  2. Instalation
  3. Dependencies
  4. Usage

Simple flash toastr notifications for Yii2

Latest Stable Version Total Downloads Latest Stable Release Date Quality Score Build Status License PHP Version Require

Yii2 Toastr uses Toastr
Demo: https://codeseven.github.io/toastr/demo.html

Table of Contents

Instalation

Package is available on Packagist, you can install it using Composer.

composer require diecoding/yii2-toastr "^1.0"

or add to the require section of your composer.json file.

"diecoding/yii2-toastr": "^1.0"

Dependencies

Usage

Layouts/Views

Add ToastrFlash to your layout or view file, example in file views\layouts\main.php

Layouts/Views Simple Usage
use diecoding\toastr\ToastrFlash;

ToastrFlash::widget();
Layouts/Views Advanced Usage
use diecoding\toastr\ToastrFlash;

ToastrFlash::widget([
    "typeDefault"       => ToastrFlash::TYPE_INFO,            // (string) default `ToastrFlash::TYPE_INFO`
    "titleDefault"      => "",                                // (string) default `""`
    "messageDefault"    => "",                                // (string) default `""`
    "closeButton"       => false,                             // (bool) default `false`
    "debug"             => false,                             // (bool) default `false`
    "newestOnTop"       => true,                              // (bool) default `true`
    "progressBar"       => true,                              // (bool) default `true`
    "positionClass"     => ToastrFlash::POSITION_TOP_RIGHT,   // (string) default `ToastrFlash::POSITION_TOP_RIGHT`
    "preventDuplicates" => true,                              // (bool) default `true`
    "showDuration"      => 300,                               // (int|null) default `300` in `ms`, `null` for skip
    "hideDuration"      => 1000,                              // (int|null) default `1000` in `ms`, `null` for skip
    "timeOut"           => 5000,                              // (int|null) default `5000` in `ms`, `null` for skip
    "extendedTimeOut"   => 1000,                              // (int|null) default `1000` in `ms`, `null` for skip
    "showEasing"        => "swing",                           // (string) default `swing`, `swing` and `linear` are built into jQuery
    "hideEasing"        => "swing",                           // (string) default `swing`, `swing` and `linear` are built into jQuery
    "showMethod"        => "slideDown",                       // (string) default `slideDown`, `fadeIn`, `slideDown`, and `show` are built into jQuery
    "hideMethod"        => "slideUp",                         // (string) default `slideUp`, `hide`, `fadeOut` and `slideUp` are built into jQuery
    "tapToDismiss"      => true,                              // (bool) default `true`
    "escapeHtml"        => true,                              // (bool) default `true`
    "rtl"               => false,                             // (bool) default `false`
    "skipCoreAssets"    => false,                             // (bool) default `false`, `true` if use custom or external toastr assets
    "options"           => [],                                // (array) default `[]`, Custom Toastr options and override default options
]);
Controllers

Just use Yii::$app->session->setFlash($type, $message) like as usual alert

Controllers Simple Usage
Yii::$app->session->setFlash('error', 'Message');

or if use multiple flash in same session

Yii::$app->session->setFlash('error', ['Message 1', 'Message 2', 'Message 3']);
Controllers Advanced Usage
Yii::$app->session->setFlash('error', [['Title', 'Message']]);

or if use multiple flash in same session

Yii::$app->session->setFlash('error', [['Title 1', 'Message 1'], ['Title 2', 'Message 2'], ['Title 3', 'Message 3']]);

Read more docs: https://sugengsulistiyawan.my.id/docs/opensource/yii2/toastr/

2 0
1 follower
16 379 downloads
Yii Version: 2.0
License: MIT
Category: User Interface
Developed by: Sugeng Sulistiyawan
Created on: Aug 10, 2018
Last updated: a year ago
Packagist Profile
Github Repository

Related Extensions