_main_view_item.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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?>" title="<?=htmlentities($model->title,ENT_QUOTES)?>">
  26. <picture class="w-100">
  27. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?>" media="(min-width: 600px)">
  28. <img src="<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?>" srcset="<?=$preview->getUrl(Image::SIZE_320x180)?>?v=<?=$model->rev?> 320w,<?=$preview->getUrl(Image::SIZE_500x282)?>?v=<?=$model->rev?> 500w,<?=$preview->getUrl(Image::SIZE_680x383)?>?v=<?=$model->rev?> 680w" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" 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?> <?=date("H:i",strtotime($model->dt_pub))?>
  38. <?php if($model->comments=="Y"):?>
  39. <?php
  40. $count=$model->getCommentsAll()->count();
  41. ?>
  42. <?php if($count>0):?>
  43. <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
  44. <?php endif;?>
  45. <?php endif;?>
  46. </div>
  47. </div>
  48. </div>
  49. <?php
  50. if($index==3) echo \yii\helpers\Html::endTag("div");
  51. ?>