Exemple #1
0
 public function actionView($alias, $lang = null, $category = null)
 {
     $model = EventsRecord::find()->lang($lang)->joinWith(['category', 'images'])->andWhere([CategoryRecord::tableName() . '.alias' => $category])->andWhere([EventsRecord::tableName() . '.alias' => $alias])->one();
     if (!$model) {
         throw new HttpException('404', 'Запись не найдена');
     }
     return $this->render('view', ['model' => $model]);
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CategoryRecord::find()->lang();
     $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]);
     $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]);
     return $dataProvider;
 }
 /**
  * @param $alias
  * @return self[]
  */
 public static function getFromCategory($alias)
 {
     return self::find()->joinWith(['category', 'image'])->lang(\Yii::$app->language)->andWhere([CategoryRecord::tableName() . '.alias' => $alias])->orderBy(['dateCreate' => SORT_DESC])->limit(2)->all();
 }
Exemple #4
0
use yii\helpers\Html;
use yii\grid\GridView;
use app\modules\article\models\CategoryRecord;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\article\models\EventsRecordSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Новости');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="events-record-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Добавить'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['class' => \app\modules\core\components\ImageColumn::className()], ['attribute' => 'categoryId', 'value' => 'category.title', 'filter' => CategoryRecord::dropdown()], 'title', 'alias', 'dateUpdate:date', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
Exemple #5
0
<?php

use app\modules\article\models\CategoryRecord;
/* @var $this yii\web\View */
/* @var $model app\modules\article\models\EventsRecord */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="events-record-form">
    <div class="well">
        <div class="row">
            <div class="col-md-6">
                <?php 
echo $form->field($model, '[' . $k . ']categoryId')->dropDownList(CategoryRecord::dropdown(), ['prompt' => 'Выбор']);
?>
                <?php 
echo $form->field($model, '[' . $k . ']title')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, '[' . $k . ']descriptionShort')->textarea(['rows' => 6]);
?>

                <?php 
echo $form->field($model, '[' . $k . ']metaKeywords')->textInput(['maxlength' => true]);
?>

                <?php 
echo $form->field($model, '[' . $k . ']metaDescription')->textarea(['maxlength' => true]);
?>
            </div>
            <div class="col-md-6">