_main_view_item.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @var $model \app\models\News
  4. * @var $key
  5. * @var $index
  6. * @var $widget
  7. */
  8. use app\models\base\Image;
  9. $preview = $model->preview;
  10. switch ($index){
  11. case 0:
  12. $className = "main";
  13. break;
  14. case 1:
  15. $className = "high";
  16. break;
  17. default:
  18. $className = "low";
  19. }
  20. if($index==2) echo \yii\helpers\Html::beginTag("div",["class"=>'group']);
  21. ?>
  22. <div class="news-item <?=$className?>" data-key="<?=$key?>">
  23. <?php if($preview instanceof Image && $index==0):?>
  24. <div class="picture-cont-16x9">
  25. <a href="<?=$model->url?>">
  26. <picture class="w-100">
  27. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383)?>" media="(min-width: 600px)">
  28. <img src="<?=$preview->getUrl(Image::SIZE_680x383)?>" alt="<?=$model->photo_title?>" class="w-100" loading="lazy">
  29. </picture>
  30. </a>
  31. </div>
  32. <?php endif;?>
  33. <div class="meta">
  34. <h2 class="title"><a href="<?=$model->url?>"><?=$model->title?></a></h2>
  35. <?php if($className!="low"): ?><div class="lead"><?=$model->lid?></div><?php endif;?>
  36. <div class="published_at">
  37. <?=$model->publishedAt?>
  38. <?php
  39. $count=$model->getCommentsAll()->count();
  40. ?>
  41. <?php if($count>0):?>
  42. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  43. <?php endif;?>
  44. </div>
  45. </div>
  46. </div>
  47. <?php
  48. if($index==3) echo \yii\helpers\Html::endTag("div");
  49. ?>