ruturajmaniyar/yii2-flash-toastr ¶
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';
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.