コード例 #1
0
 public function search($params)
 {
     $query = ContentTemplate::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->created_at) {
         $tmp = explode(' - ', $this->created_at);
         if (isset($tmp[0], $tmp[1])) {
             $query->andFilterWhere(['between', 'content_template.created_at', strtotime($tmp[0]), strtotime($tmp[1])]);
         }
     }
     $query->andFilterWhere(['content_template.id' => $this->id, 'content_template.active' => $this->active, 'content_template.can_be_deleted' => $this->can_be_deleted]);
     $query->andFilterWhere(['like', 'content_template.name', $this->name]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * @param string $slug
  *
  * @throws \yii\web\NotFoundHttpException
  * @return string
  */
 public function actionView($slug)
 {
     $contentPage = ContentPage::getDb()->cache(function () use($slug) {
         return ContentPage::find()->andWhere(['active' => 1, 'slug' => $slug])->one();
     }, ContentModule::CACHE_TIME, new TagDependency(['tags' => ContentModule::CACHE_TAG]));
     if (!$contentPage) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     // content_template_id is set in ContentUrlRule
     $templateId = Singleton::getData('content_template_id');
     if ($templateId && $this->module->enableTemplates) {
         $template = ContentTemplate::getDb()->cache(function () use($templateId) {
             return ContentTemplate::find()->andWhere(['id' => $templateId, 'active' => 1])->one();
         }, ContentModule::CACHE_TIME, new TagDependency(['tags' => ContentModule::CACHE_TAG]));
         if ($template && is_file(Yii::getAlias('@app/templates/') . $template->layout . '/layout.php')) {
             $this->layout = '@app/templates/' . $template->layout . '/layout.php';
         }
     } else {
         $this->layout = $this->module->defaultLayout;
     }
     $breadcrumbs[] = ['label' => $contentPage->name];
     //		$this->prepareBreadcrumbs($contentPage, $breadcrumbs);
     return $this->renderIsAjax('view', compact('contentPage', 'breadcrumbs'));
 }
コード例 #3
0
ファイル: _form.php プロジェクト: webvimark/ybc-content
					<?php 
    if (Yii::$app->getModule('content')->enableTemplates) {
        ?>

						<div class="col-lg-4">
							<?php 
        if (count(Yii::$app->params['mlConfig']['languages']) > 1) {
            ?>
								<br/><br/>

							<?php 
        }
        ?>

							<?php 
        $templates = ContentTemplate::find()->active()->asArray()->all();
        if (count($templates) == 1 and !$model->content_template_id) {
            $model->content_template_id = $templates[0];
        }
        ?>

							<?php 
        echo $form->field($model, 'content_template_id', ['options' => ['class' => 'required']])->dropDownList(ArrayHelper::map($templates, 'id', 'name'), ['prompt' => '']);
        ?>

						</div>

					<?php 
    }
    ?>
コード例 #4
0
ファイル: index.php プロジェクト: webvimark/ybc-content
?>
					</p>
				</div>

				<div class="col-xs-6 text-right">
					<?php 
echo GridPageSize::widget(['pjaxId' => 'content-page-grid-pjax']);
?>
				</div>
			</div>


			<?php 
Pjax::begin(['id' => 'content-page-grid-pjax']);
?>

			<?php 
echo GridView::widget(['id' => 'content-page-grid', 'dataProvider' => $dataProvider, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'layout' => '{items}<div class="row"><div class="col-sm-8">{pager}</div><div class="col-sm-4 text-right">{summary}' . GridBulkActions::widget(['gridId' => 'content-page-grid']) . '</div></div>', 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:10px']], ['attribute' => 'name', 'value' => function ($model) {
    return Html::a($model->name, ['update', 'id' => $model->id], ['data-pjax' => 0]);
}, 'format' => 'raw'], ['class' => 'webvimark\\components\\StatusColumn', 'attribute' => 'is_main', 'toggleUrl' => Url::to(['toggle-attribute', 'attribute' => 'is_main', 'id' => '_id_'])], 'type', 'slug', ['value' => function (ContentPage $model) {
    return Html::img($model->getImageUrl('small', 'menu_image'));
}, 'contentOptions' => ['width' => '10px'], 'format' => 'raw'], ['attribute' => 'parent_id', 'filter' => ArrayHelper::map(ContentPage::find()->asArray()->all(), 'id', 'name'), 'value' => 'parent.name'], ['attribute' => 'content_template_id', 'filter' => ArrayHelper::map(ContentTemplate::find()->asArray()->all(), 'id', 'name'), 'value' => 'contentTemplate.name'], ['attribute' => 'content_menu_id', 'filter' => ArrayHelper::map(ContentMenu::find()->asArray()->all(), 'id', 'name'), 'value' => 'contentMenu.name'], ['class' => 'webvimark\\components\\StatusColumn', 'attribute' => 'active', 'toggleUrl' => Url::to(['toggle-attribute', 'attribute' => 'active', 'id' => '_id_'])], ['class' => 'webvimark\\components\\SorterColumn'], ['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px; text-align:center;']]]]);
?>
		
			<?php 
Pjax::end();
?>
		</div>
	</div>
</div>