PHP code example of loveorigami / yii2-notification-wrapper
1. Go to this page and download the library: Download loveorigami/yii2-notification-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
loveorigami / yii2-notification-wrapper example snippets
public function actionIndex(){
...
Yii::$app->session->setFlash('error', 'noty error');
Yii::$app->session->setFlash('info', 'noty info');
Yii::$app->session->setFlash('success', 'noty success');
Yii::$app->session->setFlash('warning', 'noty warning');
...
return $this->render('index');
}
// or in ajax action
public function actionAjax(){
...
Yii::$app->session->setFlash('error', 'ajax error');
Yii::$app->session->setFlash('info', 'ajax info');
Yii::$app->session->setFlash('success', 'ajax success');
Yii::$app->session->setFlash('warning', 'ajax warning');
...
$data = 'Some data to be returned in response to ajax request';
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return $data;
}
use lo\modules\noty\Wrapper;
// for Bootstrap Alert
echo Wrapper::widget();
// or for Growl
echo Wrapper::widget([
'layerClass' => 'lo\modules\noty\layers\Growl',
]);
// or for Noty
echo Wrapper::widget([
'layerClass' => 'lo\modules\noty\layers\Noty',
]);
use lo\modules\noty\Wrapper;
echo Wrapper::widget([
'layerClass' => 'lo\modules\noty\layers\Noty',
'layerOptions'=>[
// for every layer (by default)
'layerId' => 'noty-layer',
'customTitleDelimiter' => '|',
'overrideSystemConfirm' => true,
'showTitle' => true,
// for custom layer
'registerAnimateCss' => true,
'registerButtonsCss' => true
],
// clientOptions
'options' => [
'dismissQueue' => true,
'layout' => 'topRight',
'timeout' => 3000,
'theme' => 'relax',
// and more for this library...
],
]);