header_comments.php 922 B

123456789101112131415161718192021
  1. <?php
  2. if(Yii::$app->deviceDetect->isMobile()) return "";
  3. $query = \app\models\base\Comments::find()->andWhere(['visible'=>'Y'])->orderBy(['created_at'=>SORT_DESC])->limit(3);
  4. $view = $this;
  5. ?>
  6. <div class="header-center__comments">
  7. <div class="header-comments">
  8. <div class="header-comments__wrapper"><h2 class="header-comments__title">Комментарии в&nbsp;эфире</h2>
  9. <?= Yii::$app->cache->getOrSet("header-comments",function () use ($query,$view){
  10. $comments= \yii\helpers\Html::beginTag("ul",["class"=>"header-comments__list"]);
  11. foreach ($query->all() as $model)
  12. {
  13. $comments.= $view->render('_header_comments_item',['model'=>$model]);
  14. }
  15. $comments.= \yii\helpers\Html::endTag("ul");
  16. return $comments;
  17. },60);
  18. ?>
  19. </div>
  20. </div>
  21. </div>