public function actionPage($id) { if (!$id) { $this->goHome(); } $page = CmsCatalog::findOne($id); return $this->render($page->template_page, ['page' => $page]); }
public function run() { //$comments = Comment::find()->where(['status' => Comment::STATUS_ACTIVE])->orderBy(['create_time' => SORT_DESC])->limit($this->maxComments)->all(); $portlet = CmsCatalog::getRootCatalogSub2($this->id, CmsCatalog::find()->all()); $rootCatalog = CmsCatalog::findOne(['id' => CmsCatalog::getRootCatalogId($this->id, CmsCatalog::find()->asArray()->all())]); $portletTitle = $rootCatalog ? $rootCatalog->title : ''; if (!($portlet && $portletTitle)) { return; } return $this->render('sideMenu', ['title' => $portletTitle, 'portlet' => $portlet]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CmsCatalog::find(); $query->orderBy(['sort_order' => SORT_ASC, 'create_time' => SORT_DESC]); $dataProvider = new ActiveDataProvider(['query' => $query]); if ($this->load($params) && !$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'is_nav' => $this->is_nav, 'sort_order' => $this->sort_order, 'page_type' => $this->page_type, 'page_size' => $this->page_size, 'click' => $this->click, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template_list', $this->template_list])->andFilterWhere(['like', 'template_show', $this->template_show])->andFilterWhere(['like', 'template_page', $this->template_page])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getCatalog() { return $this->hasOne(CmsCatalog::className(), ['id' => 'catalog_id']); }
<?php use yii\helpers\Html; use yii\widgets\DetailView; use funson86\cms\Module; /* @var $this yii\web\View */ /* @var $model app\models\CmsCatalog */ $this->title = $model->title; $this->params['breadcrumbs'][] = ['label' => Module::t('cms', 'Cms Catalogs'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="cms-catalog-view"> <p> <?php echo Html::a(Module::t('cms', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Module::t('cms', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Module::t('cms', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'parent_id', 'value' => $model->parent_id ? $model->parent->title : Module::t('cms', 'Root Catalog')], 'title', 'surname', 'brief', 'content:ntext', 'seo_title', 'seo_keywords', 'seo_description', 'banner', ['attribute' => 'is_nav', 'value' => \funson86\cms\models\YesNo::labels($model->is_nav)], 'sort_order', ['attribute' => 'page_type', 'value' => \funson86\cms\models\CmsCatalog::getCatalogPageTypeLabels($model->page_type)], 'page_size', 'template_list', 'template_show', 'template_page', 'redirect_url:url', ['attribute' => 'status', 'value' => \funson86\cms\models\Status::labels($model->status)], 'created_at:datetime', 'updated_at:datetime']]); ?> </div>
$parentCatalog = ArrayHelper::merge([0 => Module::t('blog', 'Root Catalog')], ArrayHelper::map(CmsCatalog::get(0, CmsCatalog::find()->asArray()->all()), 'id', 'label')); unset($parentCatalog[$model->id]); ?> <div class="cms-catalog-form"> <?php $form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-2\">{hint}{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]); ?> <?php echo $form->field($model, 'parent_id')->dropDownList($parentCatalog); ?> <?php echo $form->field($model, 'page_type')->dropDownList(CmsCatalog::getCatalogPageTypeLabels())->hint(Module::t('cms', 'Page need content')); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'surname')->textInput(['maxlength' => 128]); ?> <?php echo $form->field($model, 'brief')->textInput(['maxlength' => 1022]); ?> <?php
/** * Finds the CmsCatalog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CmsCatalog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CmsCatalog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
?> <tr data-key="1"> <td><?php echo $item['id']; ?> </td> <td><?php echo $item['label']; ?> </td> <td><?php echo $item['sort_order']; ?> </td> <td><?php echo CmsCatalog::getCatalogPageTypeLabels($item['page_type']); ?> </td> <td><?php echo \funson86\cms\models\YesNo::labels()[$item['is_nav']]; ?> </td> <td><?php echo \funson86\cms\models\Status::labels()[$item['status']]; ?> </td> <td> <?php if ($item['page_type'] == CmsCatalog::PAGE_TYPE_LIST) { ?> <a href="<?php
use yii\helpers\ArrayHelper; use funson86\cms\models\CmsCatalog; use mihaildev\ckeditor\CKEditor; /* @var $this yii\web\View */ /* @var $model app\models\CmsShow */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="cms-show-form"> <?php $form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-2\">{hint}{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]); ?> <?php echo $form->field($model, 'catalog_id')->dropDownList(ArrayHelper::map(CmsCatalog::get(0, CmsCatalog::find()->where(['status' => \funson86\blog\models\Status::STATUS_ACTIVE, 'page_type' => CmsCatalog::PAGE_TYPE_LIST])->asArray()->all()), 'id', 'label')); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'surname')->textInput(['maxlength' => 128]); ?> <?php echo $form->field($model, 'brief')->textInput(['maxlength' => 1022]); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getParent() { return $this->hasOne(CmsCatalog::className(), ['id' => 'parent_id']); }