partners_news.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @var $post \app\models\News
  4. * @var \yii\data\ActiveDataProvider $newsDataProvider
  5. * @var \app\models\base\NewsTopic | \app\models\base\Story $topic
  6. * @var \app\models\Design $design
  7. */
  8. /*
  9. $newsDataProvider = new \yii\data\ActiveDataProvider(
  10. [
  11. "query"=>\app\models\Kd::find()->orderBy(["order"=>SORT_ASC])->offset(3)->limit(3),
  12. "pagination" => false
  13. ]
  14. );*/
  15. //$sort = $newsDataProvider->getModels();
  16. /*
  17. $news = new \yii\data\ActiveDataProvider();
  18. $models = [];
  19. foreach( $sort as $item ){
  20. $models[] = \app\models\News::findOne($item->id);
  21. }
  22. $news->setModels($models);
  23. */
  24. use yii\helpers\Html;
  25. echo "<!-- 3 новости в ряд -->";
  26. if(!is_null($design->parent)){
  27. echo Html::tag('h2',Html::a($design->parent->title,[$design->parent->getUrl()]),['class'=>"widget-title mt-2 text-center"]);
  28. }
  29. echo Html::beginTag("div",["class"=>"partner-news row"]);
  30. echo Yii::$app->cache->getOrSet("main-page-third-row-l2-".$design->id,function () use ($newsDataProvider){
  31. return \yii\widgets\ListView::widget([
  32. "dataProvider" => $newsDataProvider,
  33. 'options' => [
  34. 'tag' => false,
  35. 'class' => 'list-wrapper',
  36. 'id' => 'list-wrapper',
  37. ],
  38. "itemOptions"=>[
  39. "tag"=>false
  40. ],
  41. "itemView" => "_partner_news_item",
  42. "layout" => "{items}"
  43. ]);
  44. },60);
  45. echo \yii\helpers\Html::endTag("div");