wide_widget.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. if( $topic instanceof \app\models\base\NewsTopic ) $url = '/news/';
  9. if( $topic instanceof \app\models\base\Story ) $url = '/story/';
  10. if( $topic instanceof \app\models\base\Tags ) $url = '/tags/';
  11. $post = Yii::$app->cache->getOrSet("main-page-wide-widget-".$design->id,function () use($newsDataProvider){
  12. return $newsDataProvider->models[0];
  13. },600);
  14. ?>
  15. <div class="wide-widget row">
  16. <div class="col-md-8">
  17. <div class="cont">
  18. <?php if($post->image instanceof \app\models\base\Image):?>
  19. <div class="picture-cont-16x9">
  20. <picture class="w-100">
  21. <source srcset="<?=$post->image->url?>" media="(min-width: 600px)">
  22. <img src="<?=$post->image->url?>" alt="<?=htmlentities($post->photo_title,ENT_QUOTES)?>" class="w-100" loading="lazy">
  23. </picture>
  24. </div>
  25. <?php endif;?>
  26. <div class="meta">
  27. <h2 class="title">
  28. <a href="<?=$post->url?>"><?=$post->title?></a>
  29. </h2>
  30. <div class="topic">
  31. <a href="<?=$design->url!=""?$design->url:$url.$topic->url?>" class="wwt"><?=$topic->title?></a>
  32. </div>
  33. <?php
  34. $comments = $post->commentsAll;
  35. if(!is_null($comments)){
  36. $count=count($comments);
  37. } else{
  38. $count = 0;
  39. }
  40. ?>
  41. <?php if($count>0 || 1):?>
  42. <div class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></div>
  43. <?php endif;?>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="adv col-md-4">
  48. <div class="cont">
  49. <?=$this->render('@app/views/_etc/banners/peregovorkaBanner')?>
  50. </div>
  51. </div>
  52. </div>