lenta_test.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use app\models\front\News;
  3. use yii\widgets\ListView;
  4. $pages = new \yii\data\Pagination(['totalCount' => 100, 'pageSize'=>5]);
  5. ?>
  6. <style>
  7. .archive .news-list .author-lenta {padding:0;}
  8. </style>
  9. <div class="archive">
  10. <div class="news-list">
  11. <?php
  12. echo Yii::$app->cache->getOrSet("archive_news-test",function () use($author, $pages){
  13. return ListView::widget([
  14. "dataProvider" => new \yii\data\ActiveDataProvider([
  15. "query"=>\app\models\front\News::find()->andwhere(['author'=>$author]),
  16. "pagination" =>$pages,
  17. "totalCount"=> 100
  18. ]),
  19. 'options' => [
  20. 'tag' => "ul",
  21. 'class' => 'list-wrapper',
  22. 'id' => 'list-wrapper',
  23. ],
  24. "itemOptions"=>[
  25. "tag"=>"li"
  26. ],
  27. "itemView" => "item_test",
  28. "layout" => "{items}{pager}"
  29. ]);
  30. },5);
  31. ?>
  32. </div>
  33. </div>