phototitle.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. use app\models\news;
  3. use yii\helpers\Html;
  4. use yii\helpers\Url;
  5. use yii\grid\ActionColumn;
  6. use yii\widgets\ListView;
  7. use yii\widgets\ActiveForm;
  8. use yii\web\View;
  9. use yii\data\SqlDataProvider;
  10. /** @var yii\web\View $this */
  11. /** @var app\models\photoSearch $searchModel */
  12. /** @var yii\data\ActiveDataProvider $dataProvider */
  13. $this->title = 'Подписи фото';
  14. $this->params['breadcrumbs'][] = ['label' => 'Новости', 'url' => ['list']];
  15. $this->params['breadcrumbs'][] = $this->title;
  16. $page = trim(Yii::$app->request->get('page'));
  17. //SELECT DISTINCT SUBSTRING_INDEX(LOWER(`photo_title`),':', -1) as `ph`, count(*) FROM `news` WHERE `photo_title` != '' && `photo_title` != "''" group by ph
  18. $sql ="SELECT DISTINCT SUBSTRING_INDEX(LOWER(`photo_title`),':', -1) as `ph`, count(*) as c FROM `news` WHERE `photo_title` != '' and `photo_title` != '\'\'' and `dt_pub` > '".Yii::$app->params['delPhotoE']."' group by ph order by c DESC";
  19. //$query = ActiveRecord::findBySql($sql);
  20. // print_r($query->asArray()->All());
  21. //$countSql = 'select count(*) ' . $sql;
  22. $dataProvider = new SqlDataProvider([
  23. 'sql' => $sql,
  24. // 'totalCount' => Yii::$app->db->createCommand($countSql)->queryScalar(),
  25. 'pagination' => [
  26. 'pageSize' => 30,
  27. ],
  28. ]);
  29. if ($this->beginCache('fdfsdtf_'.$page, ['duration' => 3600])) {
  30. ?>
  31. <div class="content">
  32. <div class="btn-group" role="group" aria-label="Basic example">
  33. <button type="button" class="btn btn-success"> </button>
  34. <button type="button" class="btn btn-primary" name="addalbums"> </button>
  35. <button type="button" name="del" class="btn btn-dark" value="yes" > </button>
  36. </div>
  37. <div class="card-body">
  38. <table class="table m-0 table-hover table-striped dataTable dtr-inline">
  39. <thead>
  40. <tr>
  41. <th>Заголовки</th>
  42. <th>Материалов</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. <?= ListView::widget([
  47. 'dataProvider' => $dataProvider,
  48. 'options' => [
  49. 'tag' => "div",
  50. 'class' => 'list-wrapper',
  51. 'id' => 'list-wrapper',
  52. ],
  53. "itemOptions"=>[
  54. "tag"=>"tr",'class' => 'dtr-control',
  55. ],
  56. "itemView" => "_itemtitle",
  57. "layout" => "\n{items}\n{pager}\n{summary}",
  58. 'pager' => [
  59. 'prevPageCssClass' => 'page-item',
  60. 'firstPageLabel' => 'Начало',
  61. 'lastPageLabel' => 'Конец',
  62. 'linkOptions' => [ 'class'=>'page-link'],
  63. 'pageCssClass' => 'page-item',
  64. 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'page-link'],
  65. ]
  66. ]) ?>
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>
  71. <?
  72. $this->endCache();
  73. }