All Projects → odai-alali → Yii2 Toastr

odai-alali / Yii2 Toastr

Yii2 wrapper for toastr javascript notification library

Labels

Projects that are alternatives of or similar to Yii2 Toastr

Yii2 App Basic
Yii 2.0 Basic Application Template
Stars: ✭ 548 (+3814.29%)
Mutual labels:  yii2
Yii2 Google Maps Markers
Google Maps Markers Widget for Yii2
Stars: ✭ 16 (+14.29%)
Mutual labels:  yii2
Yii2 App Another
Yii 2 Another Project Template
Stars: ✭ 9 (-35.71%)
Mutual labels:  yii2
Yii2admin
通用的yii2后台,基于Yii2的advanced应用程序模板,整合RBAC、Menu、Config、Migration多语言、RESTfull等等...
Stars: ✭ 619 (+4321.43%)
Mutual labels:  yii2
Opensourcewebsite Org
OpenSourceWebsite (OSW) - online community managed by users using electronic voting and modifying source code
Stars: ✭ 834 (+5857.14%)
Mutual labels:  yii2
Yii2 Fotorama Widget
Fotorama image gallery widget for yii2
Stars: ✭ 18 (+28.57%)
Mutual labels:  yii2
Cms
Feehi CMS based on yii2
Stars: ✭ 493 (+3421.43%)
Mutual labels:  yii2
Yii2 Bx Slider
bx-slider.js wrapper for yii2.
Stars: ✭ 11 (-21.43%)
Mutual labels:  yii2
Yii2 Helpers
Collection of useful helper functions for Yii Framework 2.0
Stars: ✭ 16 (+14.29%)
Mutual labels:  yii2
Yii2 Hitable Behavior
The hit countable behavior for the Yii2 framework.
Stars: ✭ 8 (-42.86%)
Mutual labels:  yii2
Dotplant2
E-Commerce CMS - Yii Framework 2 (yii2, shop)
Stars: ✭ 636 (+4442.86%)
Mutual labels:  yii2
Yii2 Fullcalendar
Widget for Yii Framework 2.0 to use FullCalendar
Stars: ✭ 5 (-64.29%)
Mutual labels:  yii2
Yii2 Telegram Log
Telegram log target for Yii 2
Stars: ✭ 24 (+71.43%)
Mutual labels:  yii2
Humhub
HumHub is an Open Source Enterprise Social Network. Easy to install, intuitive to use and extendable with countless freely available modules.
Stars: ✭ 5,586 (+39800%)
Mutual labels:  yii2
Yii2 C3 Chart
Yii2 wrapper for D3-based reusable chart library
Stars: ✭ 9 (-35.71%)
Mutual labels:  yii2
Yii2 fecshop
yii2 ( PHP ) fecmall(fecshop) core code used for ecommerce shop 多语言多货币多入口的开源电商 B2C 商城,支持移动端vue, app, html5,微信小程序微店,微信小程序商城等
Stars: ✭ 4,864 (+34642.86%)
Mutual labels:  yii2
Yii2 Selectize
selectize.js wrapper for yii2.
Stars: ✭ 18 (+28.57%)
Mutual labels:  yii2
Heavycms
HeavyDots CMS - Open source CMS based on Yii2
Stars: ✭ 12 (-14.29%)
Mutual labels:  yii2
App Basic
Base app on SkeekS CMS (Yii2)
Stars: ✭ 10 (-28.57%)
Mutual labels:  yii2
Yii2 Slack Log
Pretty Slack log target for Yii 2
Stars: ✭ 24 (+71.43%)
Mutual labels:  yii2

Yii2 Toastr Notification

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets, and makes ajax notification easy to implement.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist odaialali/yii2-toastr "*"

or add

"odaialali/yii2-toastr": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, you can test that the extension works by simply use it in your code by :

<?= \odaialali\yii2toastr\Toastr::widget([
    'toastType' => 'error',
    'message' => 'This is an error.',
    'customStyle' => false
]);?>

There are 2 main useful widgets

ToastrFlash

displays Yii flash messages in toastr notification style

<?php
$session = \Yii::$app->getSession();
$session->setFlash('error', "msg1");
$session->setFlash('danger', "msg2");
$session->setFlash('warning', "msg3");
$session->setFlash('info', "msg4");
$session->setFlash('success', "msg5");
?>
<?= \odaialali\yii2toastr\ToastrFlash::widget([
    'options' => [
        'positionClass' => 'toast-bottom-left'
    ]
]);?>

ToastrAjaxFeed

fetch notification from ajax url

<?= \odaialali\yii2toastr\ToastrAjaxFeed::widget([
    'feedUrl' => yii\helpers\Url::toRoute('/user/profile/notification-feed'),
    'interval' => 5000,
    'options' => [
        'positionClass' => 'toast-bottom-left'
    ]
]);?>

the ajax controller should return an array like this

public function actionNotificationFeed(){
    $ret = [
        [
            'type' => 'error',
            'message' => 'error message',
            'title' => 'Hey!'
        ],
        [
            'type' => 'info',
            'message' => 'another message',
            'title' => 'Hello'
        ]
    ];
    return \yii\helpers\Json::encode($ret);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].