/** * Lists all CmsCatalog models. * @return mixed */ public function actionIndex() { //if(!Yii::$app->user->can('viewYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth')); $searchModel = new CmsCatalogSearch(); $dataProvider = CmsCatalog::get(0, CmsCatalog::find()->asArray()->all()); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
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; }
public function actionList($id) { if (!$id) { $this->goHome(); } //$this->layout = 'column2'; $list = CmsCatalog::findOne($id); $ids = CmsCatalog::getArraySubCatalogId($id, CmsCatalog::find()->asArray()->all()); $query = CmsShow::find(); $query->where(['status' => Status::STATUS_ACTIVE, 'catalog_id' => $ids]); $pagination = new Pagination(['defaultPageSize' => isset(Yii::$app->params['cmsListPageCount']) ? Yii::$app->params['cmsListPageCount'] : 2, 'totalCount' => $query->count()]); $shows = $query->orderBy(['created_at' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render($list->template_list, ['list' => $list, 'shows' => $shows, 'pagination' => $pagination, 'catalogId' => $id]); }
use yii\helpers\ArrayHelper; use clh021\wechat_ionic1\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
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use clh021\wechat_ionic1\models\CmsCatalog; use clh021\wechat_ionic1\Module; use mihaildev\ckeditor\CKEditor; /* @var $this yii\web\View */ /* @var $model app\models\CmsCatalog */ /* @var $form yii\widgets\ActiveForm */ //fix the issue that it can assign itself as parent $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('wechat', 'Page need content')); ?> <?php