index.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\helpers\Url;
  4. use app\models\Inquirer;
  5. use yii\widgets\ListView;
  6. $this->title = 'Опросы';
  7. $this->params['breadcrumbs'][] = ['text' => 'Опросы', 'url' =>'/inquirer'];
  8. $url = '/inquirer';
  9. Yii::$app->og->title = $this->title;
  10. Yii::$app->og->description = 'Все опросы';
  11. Yii::$app->og->canonical = $url;
  12. \Yii::$app->og->og_url = $url;
  13. \Yii::$app->og->og_type = "article";
  14. \Yii::$app->og->og_title = htmlspecialchars(Yii::$app->og->title);
  15. \Yii::$app->og->og_description = Yii::$app->og->description;
  16. \Yii::$app->og->og_image = "/img/amic-logo.svg";
  17. $pages = 60;
  18. $query = Inquirer::find()->where([ 'active'=>'Y'])->orderBy([ 'id' => SORT_DESC]);
  19. $count = $query->count();
  20. ?>
  21. <div class="archive">
  22. <div class="row">
  23. <div class="col-md-12">
  24. <div class="news-list mx-5">
  25. <?=$this->render("/layouts/breadcrumbs")?>
  26. <?php
  27. $request = Yii::$app->request;
  28. $ppage = $request->get('page');
  29. $ppage = ($ppage)?'-'.$ppage:'';
  30. echo Yii::$app->cache->getOrSet("archive_inq-{$ppage}",function () use($query, $pages){
  31. return ListView::widget([
  32. "dataProvider" => new \yii\data\ActiveDataProvider([
  33. "query"=>$query,
  34. "pagination"=>['pageSize'=>$pages],
  35. ]),
  36. 'options' => [
  37. 'tag' => "ul",
  38. 'class' => 'list-wrapper',
  39. 'id' => 'list-wrapper',
  40. ],
  41. "itemOptions"=>[
  42. "tag"=>"li"
  43. ],
  44. "itemView" => "_item",
  45. "layout" => "{items}{pager}"
  46. ]);
  47. },1);
  48. ?>
  49. </div>
  50. </div>
  51. </div>
  52. </div>