public function actionIndex() { /* if (!\Yii::$app->user->can('index')) { throw new ForbiddenHttpException('Access denied'); } */ if (Yii::$app->user->can('superadmin')) { $sites = Qpsites::find(); $dataProvider = new ActiveDataProvider(['query' => $sites]); return $this->render('index', ['sites' => $dataProvider]); } else { throw new ForbiddenHttpException('Access denied'); } }
public function init() { //if(isset($_GET['siteParamIdForTheme'])) {$this->theme = $_GET['siteParamIdForTheme'];} //if(isset($_GET['admin'])) {$this->theme = 'admin';} //@TODO $_GET сделать через request if (isset($_GET['siteParamIdForTheme'])) { try { $this->site = Qpsites::find()->where(['theme' => $_GET['siteParamIdForTheme']])->one(); } catch (\ErrorException $e) { echo "Forbidden"; } $this->theme = $_GET['siteParamIdForTheme']; // $site = new Qpsites; //var_dump($site); exit; //$this->defaultR //\Yii::$app->view->theme->pathMap = ['app/views' => 'app/themes/landberry/views']; //\Yii::$app->view->theme->baseUrl = '@app/themes/landberry'; \Yii::$app->view->theme->pathMap = ['@app/views' => '@app/themes/' . $this->theme . '/views']; \Yii::$app->view->theme->baseUrl = '@web/themes/' . $this->theme; } }
<div class="col-sm-3 col-md-2 sidebar"> <?php echo Nav::widget(['options' => ['class' => 'nav nav-sidebar'], 'items' => [['label' => 'Добавить страницу', 'url' => ['/articles/addpage/' . $model->id]]]]); ?> </div> <div class="col-lg-10"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'title')->textInput(); ?> <?php echo $form->field($model, 'site_id')->dropDownList(ArrayHelper::map(\app\models\Qpsites::find()->all(), 'id', 'title'), ['prompt' => 'Выбрать сайт']); ?> <?php echo $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(\app\models\Categories::find()->all(), 'id', 'name'), ['prompt' => 'Выбрать категорию']); ?> <?php echo $form->field($model, 'source_id')->dropDownList(ArrayHelper::map(\app\models\Source::find()->all(), 'id', 'title'), ['prompt' => 'Выбрать источник']); ?> <?php echo $form->field($model, 'redactor')->checkbox(); ?> <?php echo $form->field($model, 'text')->textarea(['rows' => 5, 'cols' => 5, 'id' => 'my-textarea-id']); ?> <?php echo $form->field($model, 'tags')->textInput();