inquirer3.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. use yii\helpers\Html;
  9. use app\models\Inquirer;
  10. use yii\widgets\ListView;
  11. //if( YII_ENV != 'dev' ) return;
  12. $query = Inquirer::find()->where([ 'active'=>'Y'])->orderBy([ 'id' => SORT_DESC])->limit(3);
  13. $newsDataProvider = new \yii\data\ActiveDataProvider(
  14. [
  15. "query"=>$query,
  16. "pagination" =>false,
  17. ]
  18. );
  19. echo "<!-- 3 опроса в ряд -->";
  20. if(!is_null($design->parent)){
  21. echo Html::tag('h2',Html::a($design->parent->title,[$design->parent->getUrl()]),['class'=>"widget-title mt-2 text-center"]);
  22. }
  23. echo Html::beginTag("div",["class"=>"partner-news row"]);
  24. echo Yii::$app->cache->getOrSet("main-page-third-row-l2-".$design->id,function () use ($newsDataProvider){
  25. return \yii\widgets\ListView::widget([
  26. "dataProvider" => $newsDataProvider,
  27. 'options' => [
  28. 'tag' => false,
  29. 'class' => 'list-wrapper',
  30. 'id' => 'list-wrapper',
  31. ],
  32. "itemOptions"=>[
  33. "tag"=>false
  34. ],
  35. "itemView" => "_inquirer_item",
  36. "layout" => "{items}"
  37. ]);
  38. },60);
  39. echo \yii\helpers\Html::endTag("div");