ruturajmaniyar / yii2-flash-toastr
Toastr flash notification using jQuery with yii2
Installs: 3 369
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 1
Type:yii2-extension
Requires
- bower-asset/toastr: ^2.1
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-10-29 05:40:52 UTC
README
Toastr flash notification using jQuery with yii2
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';