main_view.php 797 B

123456789101112131415161718192021222324252627
  1. <?php
  2. $newsDataProvider = new \yii\data\ActiveDataProvider(
  3. [
  4. "query"=>\app\models\News::getMainView()->orderBy(["dt_pub"=>SORT_DESC])->limit(3),
  5. "pagination" =>[
  6. "pageSize"=>4
  7. ],
  8. ]
  9. );
  10. echo \yii\helpers\Html::beginTag("div",["class"=>"main-view"]);
  11. echo Yii::$app->cache->getOrSet("main-page-main-view",function () use ($newsDataProvider){
  12. return \yii\widgets\ListView::widget([
  13. "dataProvider" => $newsDataProvider,
  14. 'options' => [
  15. 'tag' => false,
  16. 'class' => 'list-wrapper',
  17. 'id' => 'list-wrapper',
  18. ],
  19. "itemOptions"=>[
  20. "tag"=>false
  21. ],
  22. "itemView" => "_main_view_item",
  23. "layout" => "{items}"
  24. ]);
  25. },600);
  26. echo \yii\helpers\Html::endTag("div");