<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ ?> <?php // если пользователь модератор if (Yii::$app->user->identity->role_id == app\models\Role::getIdByName('moderator')) { $this->title = 'Статьи'; } else { $this->title = 'Мои статьи'; } ?> <div class="news-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'title', 'slug', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin([]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Home', 'url' => ['/news/index']], !Yii::$app->user->isGuest && Yii::$app->user->identity->role_id == app\models\Role::getIdByName('moderator') ? ['label' => 'Панель администратора', 'items' => [['label' => 'Профили пользователей', 'url' => ['/user/index']], ['label' => 'Неопубликованные статьи', 'url' => ['/news/unpublished']]]] : ['label' => '', 'visible' => FALSE], !Yii::$app->user->isGuest && Yii::$app->user->identity->role_id == app\models\Role::getIdByName('writer') ? ['label' => 'Мой профиль', 'items' => [['label' => 'Редактировать профиль', 'url' => ['/user/' . Yii::$app->user->identity->id]], ['label' => 'Мои статьи', 'url' => ['/news/articles/' . Yii::$app->user->identity->id]]]] : ['label' => '', 'visible' => FALSE], Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/news/login']] : ['label' => 'Logout (' . Yii::$app->user->identity->email . ')', 'url' => ['/news/logout'], 'linkOptions' => ['data-method' => 'post']]]]); NavBar::end(); ?> <div class="container"> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo $content; ?> </div> </div> <?php $this->endBody(); ?>