Search code examples
push-notificationyii2growladminlte

Growl Widget Kartik with AdminLTE template


How i can intregate Growl Widget Kartik Yii2 with AdminLTE Template. When i used the widget not show the animation and position defined from Controller.

CompraController.php

...   if ($flag) {
                        $transaction->commit();
                        Yii::$app->getSession()->setFlash('success', [
                             'type' => 'success',
                             'duration' => 5000,
                             'icon' => 'glyphicon glyphicon-ok',
                             'message' => ' Compra Registrada ;)',
                             'title' => 'Registro Compra',
                             'positonY' => 'top',
                             'positonX' => 'right'
                         ]);
                        return $this->redirect(['index']);
                    }

main.php

...  <?php foreach (Yii::$app->session->getAllFlashes() as $message):; ?>
        <?php
        echo Growl::widget([
            'type' => (!empty($message['type'])) ? $message['type'] : 'danger',
            'title' => (!empty($message['title'])) ? Html::encode($message['title']) : 'Title Not Set!',
            'icon' => (!empty($message['icon'])) ? $message['icon'] : 'fa fa-info',
            'body' => (!empty($message['message'])) ? Html::encode($message['message']) : 'Message Not Set!',
            'showSeparator' => true,
            'delay' => 1, //This delay is how long before the message shows
            'pluginOptions' => [
                'delay' => (!empty($message['duration'])) ? $message['duration'] : 3000, //This delay is how long the message shows for
                'placement' => [
                    'from' => (!empty($message['positonY'])) ? $message['positonY'] : 'top',
                    'align' => (!empty($message['positonX'])) ? $message['positonX'] : 'right',
                ]
            ],
            'useAnimation'=>true
        ]);
        ?>
    <?php endforeach; ?>

When i use the normal template of Yii2 works fine:

enter image description here

But when i use the AdminLTE template, every option is trated like a different notification:

enter image description here


Solution

  • Apparently the AdminLTE Template it has its own notification methods that prevent the execution of Growl Widget. I remove the line: <?= Alert::widget() ?> in:

    <section class="content"> <?= Alert::widget() ?> <?= $content ?> </section>

    from the file views/layout/content.php and works fine.