12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- use app\models\base\TopSlider;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\grid\ActionColumn;
- use yii\grid\GridView;
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
- //print_a($dataProvider->query->createCommand()->rawSQL);
- //print_a($dataProvider->getModels());
- //$dataProvider->getModels()->toArray([]);exit;
- $this->title = 'Содержимое слайдера';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="top-slider-index">
- <p>
- <?= Html::a('Добавить новость', ['create'], ['class' => 'btn btn-success']) ?>
- </p>
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
- [
- 'attribute'=>'новость',
- 'value' => 'post_id'
- ],
- [
- 'attribute' => 'Фото',
- 'format' => 'html',
- 'value' => function ($model) {return Html::img(Yii::getAlias('@web').'/images/news/news/'. $model['id'].".jpg", ['width' => '90px']);},
- ],
- [
- 'attribute'=>'Заголовок',
- 'format' => 'html',
- 'value' => function ($model) {return Html::a( $model['title'], '/news/'.$model['id'] );},
- ],
- [
- 'attribute'=>'Дата начала',
- 'value' => 'published_from',
- ],
- [
- 'attribute'=>'Дата окончания',
- 'value' => 'published_to',
- ],
- [
- 'class' => ActionColumn::className(),
- 'urlCreator' => function ($action, $model, $key, $index, $column) {
- return Url::toRoute([$action, 'id' => $model['ts_id']]);
- }
- ],
- ],
- ]); ?>
- </div>
|