partners_news.php 858 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * @var integer $topic_id
  4. */
  5. $newsDataProvider = new \yii\data\ActiveDataProvider(
  6. [
  7. "query"=>\app\models\News::find()->joinWith("topics t")->andWhere(["t.id"=>[$topic_id,]]),
  8. "pagination" =>[
  9. "pageSize"=>3
  10. ],
  11. ]
  12. );
  13. echo \yii\helpers\Html::beginTag("div",["class"=>"partner-news row"]);
  14. echo Yii::$app->cache->getOrSet("main-page-third-row-".$topic_id,function () use ($newsDataProvider){
  15. return \yii\widgets\ListView::widget([
  16. "dataProvider" => $newsDataProvider,
  17. 'options' => [
  18. 'tag' => false,
  19. 'class' => 'list-wrapper',
  20. 'id' => 'list-wrapper',
  21. ],
  22. "itemOptions"=>[
  23. "tag"=>false
  24. ],
  25. "itemView" => "_partner_news_item",
  26. "layout" => "{items}"
  27. ]);
  28. },600);
  29. echo \yii\helpers\Html::endTag("div");