Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = NewsCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'weight' => $this->weight, 'status_id' => $this->status_id, 'created_at' => $this->created_at, 'created_id' => $this->created_id, 'updated_at' => $this->updated_at, 'updated_id' => $this->updated_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = NewsCategory::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'tree' => $this->tree, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'layout', $this->layout]);
     return $dataProvider;
 }
Example #3
0
?>

    <?php 
echo $form->field($model, 'file')->fileInput();
?>

    <?php 
echo $model->image ? '<img src="/' . Yii::$app->params['news']['image']['path'] . $model->image . '" height="' . Yii::$app->params['news']['image']['height'] . '">' : '';
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>

    <?php 
$listdata = ArrayHelper::map(NewsCategory::find()->all(), 'id', 'title');
?>
    <?php 
echo $form->field($model, 'category_id')->dropDownList($listdata, ['class' => 'form-control select']);
?>

    <?php 
echo $form->field($model, 'tag')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'text')->widget(Widget::className(), ['settings' => ['lang' => 'ru', 'minHeight' => 100, 'plugins' => ['clips', 'fullscreen'], 'imageUpload' => Url::to(['/site/default/image-upload', 'id' => $model->id, 'type' => 'news']), 'imageManagerJson' => Url::to(['/site/default/images-get', 'id' => $model->id, 'type' => 'news'])]]);
$form->field($model, 'weight')->textInput();
?>

    <?php 
Example #4
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="news-category-index">

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

    <p>
        <?php 
echo Html::a('&larr; News', ['news/list'], ['class' => 'btn btn-default']);
?>
        <?php 
echo Html::a('<i class="glyphicon glyphicon-plus"></i> Create News Category', ['update'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
Pjax::begin(['id' => 'news-category']);
?>
        <?php 
echo sibds\widgets\Nestable::widget(['autoQuery' => \app\modules\news\models\NewsCategory::find()]);
?>
    <?php 
Pjax::end();
?>
</div>
Example #5
0
<?php

/**
 * Created by PhpStorm.
 * User: vadim
 * Date: 05.03.16
 * Time: 15:59
 */
echo $form->field($model, 'category_id')->widget(\kartik\widgets\Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(\app\modules\news\models\NewsCategory::find()->all(), 'id', 'name'), 'addon' => ['prepend' => ['content' => \yii\bootstrap\Html::icon('list')]]]);
?>

<?php 
echo $form->field($model, 'layout')->widget(\kartik\select2\Select2::className(), ['data' => Yii::$app->controller->getLayouts(), 'options' => ['placeholder' => 'Значение по умолчанию'], 'addon' => ['prepend' => ['content' => \yii\bootstrap\Html::icon('open-file')]]]);
?>

<?php 
echo $form->field($model, 'date_public')->widget(\kartik\widgets\DatePicker::className(), ['type' => \kartik\widgets\DatePicker::TYPE_COMPONENT_APPEND, 'value' => \Yii::$app->formatter->asDate(new \DateTime(), 'short'), 'pluginOptions' => ['autoclose' => true]]);
?>

<?php 
echo $form->field($model, 'locked', ['template' => '{input}{label}{error}{hint}'])->widget(\kartik\checkbox\CheckboxX::className(), ['pluginOptions' => ['threeState' => false]]);
 /**
  * Finds the NewsCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return NewsCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = NewsCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }