12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * @var integer $topic_id
- */
- $topic = \app\models\base\NewsTopic::findOne(["id"=>$topic_id]);
- $topic_picture = $topic->image;
- ?>
- <div class="row topic-widget">
- <div class="col-md-12">
- <div class="cont">
- <?php if($topic_picture instanceof \app\models\TopicImages):?>
- <picture class="w-100">
- <source srcset="<?=$topic_picture->url?>" media="(min-width: 600px)">
- <img src="<?=$topic_picture->url?>" alt="<?=$topic_picture->alt?>" class="w-100" loading="lazy">
- </picture>
- <?php endif;?>
- <div class="content">
- <div class="topic-title">
- <?=$topic->title?>
- </div>
- <div class="topic-news">
- <?php
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>\app\models\News::find()->joinWith("topics t")->andWhere(["t.id"=>[$topic_id,]]),
- "pagination" =>[
- "pageSize"=>4
- ],
- ]
- );
- echo Yii::$app->cache->getOrSet("main-page-topic-widget-".$topic_id,function () use ($newsDataProvider){
- return \yii\widgets\ListView::widget([
- "dataProvider" => $newsDataProvider,
- 'options' => [
- 'tag' => false,
- 'class' => 'list-wrapper',
- 'id' => 'list-wrapper',
- ],
- "itemOptions"=>[
- "tag"=>false
- ],
- "itemView" => "_topic_widget_item",
- "layout" => "{items}"
- ]);
- },1);
- ?>
- </div>
- </div>
- </div>
- </div>
- </div>
|