izemize/yii2-noty

Yii widget for Noty jQuery notification plugin

Maintainers

Details

github.com/izemize/yii2-noty

Source

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 4

Type:yii2-extension

v1.0.1 2016-01-10 09:21 UTC

This package is not auto-updated.

Last update: 2024-05-03 17:43:39 UTC


README

Yii2 widget for Noty jQuery notification plugin, Visit Noty

For Yii1: Please check yii-noty

Installation:

The preferred way to install this extension is through composer

Note: The instructions below refer to the global composer installation. You might need to replace composer with php composer.phar (or similar) for your setup.

Direct install:

composer require shifrin/yii2-noty 1.0.1

or add it manually to the composer.json and update composer

"shifrin/yii2-noty": "1.0.1",
composer update

Usage Details:

Add the widget in your main layout file like below,

\shifrin\noty\NotyWidget::widget([
  'options' => [ // you can add js options here, see noty plugin page for available options
    'dismissQueue' => true,
    'layout' => 'topCenter',
    'theme' => 'relax',
    'animation' => [
      'open' => 'animated flipInX',
      'close' => 'animated flipOutX',
    ],
    'timeout' => false
  ],
  'enableSessionFlash' => true
  'enableIcon' => true,
  'registerAnimateCss' => true,
  'registerButtonsCss' => true,
  'registerFontAwesomeCss' => true,
]);

This widget will create a JS function Noty(), so it will be available globally and you can call this function in your custom JS codes. See the following example below

var n = Noty('id');
$.noty.setText(n.options.id, 'Welcome to our site!');
$.noty.setType(n.options.id, 'information');

You can set the flash messages like this in your controller or anywhere you need. However, if you set enableSessionFlash to false it won't be affected.

\Yii::$app->session->setFlash('type', 'Message here');

Replace type with available types

Available Types:

  • success
  • error
  • warning
  • information
  • alert