text_news_widget.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $newsDataProvider = new \yii\data\ActiveDataProvider(
  3. [
  4. "query"=>\app\models\News::getMainOfWeek()->orderBy(["dt_pub"=>SORT_DESC])->limit(3),
  5. "pagination" =>[
  6. "pageSize"=>4
  7. ],
  8. ]
  9. );
  10. ?>
  11. <div class="text-news-widget row">
  12. <div class="col-md-12">
  13. <div class="cont">
  14. <div class="widget-title">
  15. Главное за неделю
  16. </div>
  17. <div class="row">
  18. <?php
  19. echo Yii::$app->cache->getOrSet("main-page-text-widget",function () use ($newsDataProvider){
  20. return \yii\widgets\ListView::widget([
  21. "dataProvider" => $newsDataProvider,
  22. 'options' => [
  23. 'tag' => false,
  24. 'class' => 'list-wrapper',
  25. 'id' => 'list-wrapper',
  26. ],
  27. "itemOptions"=>[
  28. "tag"=>false
  29. ],
  30. "itemView" => "_text_widget_item",
  31. "layout" => "{items}"
  32. ]);
  33. },1);
  34. ?>
  35. </div>
  36. </div>
  37. </div>
  38. </div>