Пример #1
0
 public function actionView($slug)
 {
     $model = ContentCategory::find()->joinWith(['translations'])->where(['{{%content_category_lang}}.slug' => $slug])->one();
     if ($model === null) {
         throw new NotFoundHttpException(\Yii::t('system', 'The requested page does not exist.'));
     }
     $breadcrumbs = Menu::getBreadcrumbs('content/' . $slug);
     if (count($breadcrumbs) == 0) {
         $breadcrumbs = ['label' => $model->title];
     }
     $dataProvider = new ActiveDataProvider(['query' => ContentArticles::find()->andWhere(['category_id' => $model->id])->orderBy(['published_at' => SORT_DESC])->published(), 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false, 'pageSizeParam' => false]]);
     return $this->render('view', ['breadcrumbs' => $breadcrumbs, 'model' => $model, 'dataProvider' => $dataProvider]);
 }
Пример #2
0
 public function actionView($catslug, $slug)
 {
     $categoryModel = ContentCategory::find()->published()->joinWith(['translations'])->andWhere(['{{%content_category_lang}}.slug' => $catslug])->one();
     $model = ContentArticles::find()->published()->joinWith(['translations'])->andWhere(['{{%content_articles_lang}}.slug' => $slug])->one();
     if ($model === null and $categoryModel === null) {
         throw new NotFoundHttpException(\Yii::t('system', 'The requested page does not exist.'));
     }
     $breadcrumbs = Menu::getBreadcrumbs('content/' . $catslug . '/' . $slug);
     if (count($breadcrumbs) == 0) {
         $breadcrumbs = [['label' => $categoryModel->title, 'url' => Url::to(['/content/category/view', 'slug' => $categoryModel->slug])], ['label' => $model->title]];
     }
     return $this->render('view', ['breadcrumbs' => $breadcrumbs, 'model' => $model, 'categoryModel' => $categoryModel]);
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ContentCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'tree' => $this->tree, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'icon_type' => $this->icon_type, 'active' => $this->active, 'selected' => $this->selected, 'disabled' => $this->disabled, 'readonly' => $this->readonly, 'visible' => $this->visible, 'collapsed' => $this->collapsed, 'movable_u' => $this->movable_u, 'movable_d' => $this->movable_d, 'movable_l' => $this->movable_l, 'movable_r' => $this->movable_r, 'removable' => $this->removable, 'removable_all' => $this->removable_all]);
     $query->andFilterWhere(['like', 'icon', $this->icon]);
     return $dataProvider;
 }
Пример #4
0
 public function api_cats()
 {
     return ContentCategory::cats();
 }
Пример #5
0
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('admin', 'Content Articles');
$this->params['breadcrumbs'][] = $this->title;
$this->params['actions_buttons'] = [['tagName' => 'a', 'label' => Yii::t('admin', 'Create'), 'options' => ['href' => Url::to(['create'])], 'icon' => 'fa fa-plus', 'iconPosition' => Button::ICON_POSITION_LEFT, 'size' => Button::SIZE_SMALL, 'disabled' => false, 'block' => false, 'type' => Button::TYPE_CIRCLE], ['label' => Yii::t('app', 'Control'), 'options' => ['class' => 'btn blue btn-outline btn-circle btn-sm', 'data-hover' => "dropdown", 'data-close-others' => "true"], 'dropdown' => ['options' => ['class' => 'pull-right'], 'encodeLabels' => false, 'items' => [['label' => '<span class="font-red"><i class="fa fa-trash-o"></i> ' . Yii::t('app', 'Delete') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'deleteA()']], ['label' => '<span class="font-green-turquoise"><i class="fa fa-toggle-on"></i> ' . Yii::t('app', 'Published') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'publishedA()']], ['label' => '<span class="font-blue-chambray"><i class="fa fa-toggle-off"></i> ' . Yii::t('app', 'Unpublished') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'unpublishedA()']]]]]];
?>
<div class="content-articles-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
    <div class="table-responsive">
        <?php 
\yii\widgets\Pjax::begin();
?>
        <?php 
echo GridView::widget(['id' => 'grid', 'tableOptions' => ['class' => 'table table-striped table-bordered table-advance table-hover'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:36px']], ['attribute' => 'id', 'options' => ['style' => 'width:100px']], 'title', 'slug', ['attribute' => 'category_id', 'format' => 'raw', 'filter' => Html::activeDropDownList($searchModel, 'category_id', \yii\helpers\ArrayHelper::map(\app\modules\content\models\ContentCategory::find()->published()->all(), 'id', 'title'), ['class' => 'form-control', 'prompt' => Yii::t('admin', 'Select Category')]), 'value' => function ($model, $index, $widget) {
    return $model->category->title;
}], 'published_at:datetime', ['class' => \app\modules\admin\components\grid\EnumColumn::className(), 'attribute' => 'status', 'format' => 'raw', 'options' => ['width' => '50px'], 'value' => function ($model, $index, $widget) {
    return Html::checkbox('', $model->status == ContentArticles::STATUS_PUBLISHED, ['class' => 'switch toggle', 'data-id' => $model->primaryKey, 'data-link' => \yii\helpers\Url::to(['/admin/content/article']), 'data-reload' => '0']);
}, 'enum' => [Yii::t('app', 'Off'), Yii::t('app', 'On')]], ['class' => 'app\\modules\\admin\\components\\grid\\ActionColumn', 'translatable' => true]]]);
?>
        <?php 
\yii\widgets\Pjax::end();
?>
    </div>
</div>
<script>
    function deleteA() {
        var keys = $('#grid').yiiGridView('getSelectedRows');
        window.location.href = '/admin/content/article/delete-ids?id=' + keys.join();
    }
Пример #6
0
        }
    }
    $langueBtn = ['label' => '<img src="' . $asset->baseUrl . '/images/flags/' . $lang->url . '.png" alt="' . $lang->url . '"/> ' . $lang->name, 'options' => ['class' => 'btn blue btn-outline btn-circle btn-sm', 'data-hover' => "dropdown", 'data-close-others' => "true"], 'encodeLabel' => false, 'dropdown' => ['encodeLabels' => false, 'options' => ['class' => 'pull-right'], 'items' => $langueBtnItems]];
}
$this->params['actions_buttons'] = [$langueBtn, ['label' => $model->isNewRecord ? Yii::t('admin', 'Create') : Yii::t('admin', 'Update'), 'options' => ['form' => 'category-form-id', 'type' => 'submit'], 'icon' => 'fa fa-save', 'iconPosition' => Button::ICON_POSITION_LEFT, 'size' => Button::SIZE_SMALL, 'disabled' => false, 'block' => false, 'type' => Button::TYPE_CIRCLE, 'color' => 'btn-success'], ['label' => Yii::t('admin', 'Save & Continue Edit'), 'options' => ['onclick' => 'sendFormReload("#category-form-id")'], 'icon' => 'fa fa-check-circle', 'iconPosition' => Button::ICON_POSITION_LEFT, 'size' => Button::SIZE_SMALL, 'disabled' => false, 'block' => false, 'type' => Button::TYPE_CIRCLE, 'color' => 'btn-success']];
$form = \app\modules\admin\widgets\ActiveForm::begin(['enableAjaxValidation' => true, 'options' => ['enctype' => 'multipart/form-data', 'id' => 'category-form-id']]);
?>

    <?php 
echo $form->field($model, 'title');
?>
    <?php 
echo $form->field($model, 'slug')->hint(Yii::t('admin', 'If you\'ll leave this field empty, slug will be generated automatically'));
?>
    <?php 
echo isset($parent) ? $form->field($model, 'parent')->dropDownList(ArrayHelper::map(ContentCategory::find()->andFilterWhere(['<>', 'id', $model->id])->all(), 'id', 'title'), ['prompt' => '']) : '';
?>

    <?php 
if ($settings['categoryThumb']['value']) {
    ?>

    <?php 
}
?>

    <?php 
echo $form->field($model, 'meta_title')->textInput();
?>
    <?php 
echo $form->field($model, 'meta_keywords')->textInput();
Пример #7
0
?>
" class="text-muted">
                    <i class="fa fa-gear"></i>
                </a>
            </li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="tab_1">
                <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true])->translatable();
?>
                <?php 
echo $form->field($model, 'slug')->hint(Yii::t('admin', 'If you\'ll leave this field empty, slug will be generated automatically'))->textInput(['maxlength' => true])->translatable();
?>
                <?php 
echo $form->field($model, 'category_id')->dropDownList(\yii\helpers\ArrayHelper::map(\app\modules\content\models\ContentCategory::find()->published()->all(), 'id', 'title'));
?>
                <?php 
echo $form->field($model, 'description')->widget(\app\widgets\Editor::className())->translatable();
?>
                <?php 
echo $form->field($model, 'content')->widget(\app\widgets\Editor::className())->translatable();
?>
                <div class="form-group">
                    <div class="row">
                        <div class="col-md-3">

                        </div>
                        <div class="col-md-9">
                            <?php 
echo Html::img($model->getUploadUrl('image') ?: '/uploads/user/non_image.png', ['class' => 'img-thumbnail', 'style' => 'max-width:300px']);
Пример #8
0
 public function getCategory()
 {
     return $this->hasOne(ContentCategory::className(), ['id' => 'category_id']);
 }
Пример #9
0
 /**
  * Finds the ContentCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ContentCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ContentCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }