12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- $topic_id = 136;//Переговорка
- $topic = \app\models\base\NewsTopic::findOne(['id'=>$topic_id]);
- /**
- * @var $post \app\models\News
- */
- $post = Yii::$app->cache->getOrSet("main-page-wide-widget",function () use($topic_id){
- return \app\models\News::find()
- ->alias('n')
- ->joinWith('topics')
- ->with('commentsAll')
- ->andWhere(['news_topic.id'=>$topic_id])
- ->orderBy(['dt_pub'=>SORT_DESC])
- ->one();
- },600);
- ?>
- <div class="wide-widget row">
- <div class="col-md-8">
- <div class="cont">
- <?php if($post->image instanceof \app\models\base\Image):?>
- <div class="picture-cont-16x9">
- <picture class="w-100">
- <source srcset="<?=$post->image->url?>" media="(min-width: 600px)">
- <img src="<?=$post->image->url?>" alt="<?=$post->photo_title?>" class="w-100" loading="lazy">
- </picture>
- </div>
- <?php endif;?>
- <div class="meta">
- <h2 class="title">
- <a href="<?=$post->url?>"><?=$post->title?></a>
- </h2>
- <div class="topic">
- <?=$topic->title?>
- </div>
- <?php
- $comments = $post->commentsAll;
- if(!is_null($comments)){
- $count=count($comments);
- } else{
- $count = 0;
- }
- ?>
- <?php if($count>0 || 1):?>
- <div class="commnets"> <svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></div>
- <?php endif;?>
- </div>
- </div>
- </div>
- <div class="adv col-md-4">
- <div class="cont">
- </div>
- </div>
- </div>
|