12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- use app\models\news;
- use yii\helpers\Html;
- use yii\helpers\Url;
- use yii\grid\ActionColumn;
- use yii\widgets\ListView;
- use yii\widgets\ActiveForm;
- use yii\web\View;
- use yii\data\SqlDataProvider;
- /** @var yii\web\View $this */
- /** @var app\models\photoSearch $searchModel */
- /** @var yii\data\ActiveDataProvider $dataProvider */
- $search = trim(Yii::$app->request->get('s'));
- $page = trim(Yii::$app->request->get('page'));
- $this->title = 'Подписи фото'."-".$search;
- $this->params['breadcrumbs'][] = ['label' => 'Подписи фото', 'url' => ['phototitle']];
- $this->params['breadcrumbs'][] = $search;
- /*
- //SELECT DISTINCT SUBSTRING_INDEX(LOWER(`photo_title`),':', -1) as `ph`, count(*) FROM `news` WHERE `photo_title` != '' && `photo_title` != "''" group by ph
- $sql ="SELECT * FROM `news` WHERE `photo_title` like '%".$search."%' order by dt_pub";
- //$query = ActiveRecord::findBySql($sql);
- // print_r($query->asArray()->All());
- //$countSql = 'select count(*) ' . $sql;
- $dataProvider = new SqlDataProvider([
- 'sql' => $sql,
- // 'totalCount' => Yii::$app->db->createCommand($countSql)->queryScalar(),
- 'pagination' => [
- 'pageSize' => 30,
- ],
- ]);
- */
- if ($this->beginCache('fd2fsdtf_'.$page.$search, ['duration' => 3600])) {
- $dataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>\app\models\front\News::find()->andWhere(['like', 'photo_title', trim($search)])->orderBy(['dt_pub'=>SORT_DESC]),
- 'pagination' => [
- 'pageSize' => 30,
- ],
- ]
- );
- ?>
- <div class="content">
- <table class="table m-0 table-hover table-striped dataTable dtr-inline">
- <thead>
- <tr>
- <th>фото</th>
- <th>дата</th>
- <th>Статья</th>
- <th>Фото подпись</th>
- </tr>
- </thead>
- <?= ListView::widget([
- 'dataProvider' => $dataProvider,
- 'options' => [
- 'tag' => "div",
- 'class' => 'list-wrapper',
- 'id' => 'list-wrapper',
- ],
- "itemOptions"=>[
- "tag"=>"tr",'class' => '',
- ],
- "itemView" => "_itemtitles",
- "layout" => "{items}\n{pager}\n{summary}",
- 'pager' => [
- 'prevPageCssClass' => 'page-item',
- 'firstPageLabel' => 'Начало',
- 'lastPageLabel' => 'Конец',
- 'linkOptions' => [ 'class'=>'page-link'],
- 'pageCssClass' => 'page-item',
- 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
- ]
- ]) ?>
- </table>
- </div>
- <?
- $this->endCache();
- }
|