header_comments.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. $newsDataProvider = new \yii\data\ActiveDataProvider(
  3. [
  4. "query"=>\app\models\base\Comments::find()->andWhere(['need_moderation'=>0])
  5. ->leftJoin(["p"=>\app\models\base\OldNews::tableName()],'p.comment_pull_id = comments.comment_pull_id')
  6. ->andWhere(['is not','p.id',new \yii\db\Expression('NULL')])
  7. ->orderBy(['id'=>SORT_DESC]),
  8. "pagination" =>[
  9. "pageSize"=>3
  10. ],
  11. ]
  12. );
  13. ?>
  14. <div class="header-center__comments">
  15. <div class="header-comments">
  16. <div class="header-comments__wrapper"><h2 class="header-comments__title">Комментарии в&nbsp;эфире</h2>
  17. <?= Yii::$app->cache->getOrSet("header-comments",function () use ($newsDataProvider){
  18. $sql = $newsDataProvider->query->createCommand()->getRawSql();
  19. return \yii\widgets\ListView::widget([
  20. "dataProvider" => $newsDataProvider,
  21. 'options' => [
  22. 'tag' => "ul",
  23. 'class' => 'header-comments__list',
  24. 'id' => false,
  25. ],
  26. "itemOptions"=>[
  27. "tag"=>false
  28. ],
  29. "itemView" => "_header_comments_item",
  30. "layout" => "{items}"
  31. ]);
  32. },1);
  33. ?>
  34. </div>
  35. </div>
  36. </div>