Browse Source

Notification widget fix zero count

master
Egorka 6 years ago
parent
commit
d115294956
  1. 7
      backend/widgets/NotificationCountWidget.php
  2. 2
      backend/widgets/views/notification-count.php
  3. 1
      common/modules/banners/widgets/BannerWidget.php

7
backend/widgets/NotificationCountWidget.php

@ -14,12 +14,15 @@ class NotificationCountWidget extends Widget
public function run()
{
$count = 0;
foreach (\Yii::$app->params['notifications'] as $notification) {
if (isset(\Yii::$app->params['notifications'])) {
foreach ( \Yii::$app->params['notifications'] as $notification ) {
$count += $notification['count'];
}
}
return $this->render('notification-count', [
'notifications' => \Yii::$app->params['notifications'],
'notifications' => isset(\Yii::$app->params['notifications']) ? \Yii::$app->params['notifications'] : [],
'count' => $count,
]);
}

2
backend/widgets/views/notification-count.php

@ -17,7 +17,9 @@ use yii\helpers\Url;
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<?php if ($count > 0): ?>
<span class="label label-warning"><?= $count ?></span>
<?php endif; ?>
</a>
<ul class="dropdown-menu">
<li class="header"><?= Yii::t('main', 'You have {count} notifications', ['count' => $count]) ?></li>

1
common/modules/banners/widgets/BannerWidget.php

@ -8,7 +8,6 @@ namespace common\modules\banners\widgets;
use common\modules\banners\entities\Banner;
use common\modules\banners\entities\BannerPlace;
use common\modules\banners\helpers\BannerHelper;
use yii\base\Widget;
class BannerWidget extends Widget

Loading…
Cancel
Save