Ejemplo n.º 1
0
 public function actionCreate()
 {
     $model = new Qpsites();
     if ($model->load(Yii::$app->request->post())) {
         //$userModel = Yii::$app->user->identity; //так получаем модель Юзера
         $model->title = Yii::$app->request->post('Qpsites')['title'];
         $model->url = Yii::$app->request->post('Qpsites')['url'];
         $model->theme = Yii::$app->request->post('Qpsites')['theme'];
         $model->user_id = Yii::$app->user->identity->getId();
         $model->save(false);
         return $this->render('code', ['model' => $model]);
         //return $this->redirect(Url::toRoute('qpsites/index'));
     } else {
         return $this->render('_form', ['model' => $model]);
     }
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
        <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();