Bladeren bron

off add fast tags

amic 1 jaar geleden
bovenliggende
commit
847d7b7044
3 gewijzigde bestanden met toevoegingen van 95 en 1 verwijderingen
  1. 1 1
      models/base/TagsRelation.php
  2. 51 0
      views/layouts/lenta/_item_right.php
  3. 43 0
      views/layouts/lenta/lenta_right.php

+ 1 - 1
models/base/TagsRelation.php

@@ -62,7 +62,7 @@ class TagsRelation extends BaseFrontendClass
 					'type' => 'news'
 				])->execute();
 			}else{
-				if( mb_strlen( $item ) > 2 ){	//совсем мусор
+				if( mb_strlen( $item ) > 2 && 0 ){	//совсем мусор #отключено простое добавление, стали заводить мусор
 					$tags = new Tags();
 					$r = $tags->simpleAdd($item);
 					if( $r !== false && $r*1 > 0 ){

+ 51 - 0
views/layouts/lenta/_item_right.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ * @var $model \app\models\News
+ * @var $index integer
+ */
+use app\models\base\Image;
+
+$preview = $model->image;
+
+$retina = $preview->getUrl(Image::SIZE_680x383,"webp");
+$normal = $preview->getUrl(Image::SIZE_320x180,"webp");
+$bad = $preview->getUrl(Image::SIZE_320x180,'jpg');
+
+$bad = $bad?$bad:'/images/default.jpg';
+
+if( $retina === false || $normal == false ){
+	$normal = $bad;
+	$retina = $bad;
+}
+$normal .= "?v=".$model->rev;
+$retina .= "?v=".$model->rev;
+$bad .= "?v=".$model->rev;
+
+if(  $model->photo_rcol == 'Y' ){
+?>
+        <div class="card-body mb-2">
+            <?php if($preview instanceof \app\models\base\Image):?>
+                <div class="picture-cont-16x9">
+                    <a href="<?=$model->url?>">
+                        <picture class="w-100">
+                            <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
+                            <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> 2x" class="w-100" <?=($index > 2)?'loading="lazy"':''?>>
+                        </picture>
+                    </a>
+                </div>
+            <?php endif;?>
+        </div>
+<?}?>
+<h3>
+    <?=\yii\helpers\Html::a($model->title,$model->url);?>
+    <div class="published_at">
+        <?=($model->dt_pub<date("Y-m-d H:i:s",strtotime("-1 day")))?date("d.m.Y H:i",strtotime($model->dt_pub)):$model->publishedAt?>
+        <?php
+        $count=$model->getCommentsAll()->count();
+        ?>
+        <?php if($count>0):?>
+            <span class="commnets">&nbsp;<svg class="icon icon-comments"><use xlink:href="/svg/symbol/sprite-clear.svg#comments"></use></svg><?=$count?></span>
+        <?php endif;?>
+    </div>
+</h3>
+

+ 43 - 0
views/layouts/lenta/lenta_right.php

@@ -0,0 +1,43 @@
+<?php
+
+use app\models\front\News;
+
+$keyadd = News::keyFilter();
+?>
+<a class="news-link" href="/news">Лента новостей</a>
+<?php if( Yii::$app->controller->action->id!="index") echo $this->render("@app/views/_etc/banners/desktopLentBannerVideo"); ?>
+<div class="lenta">
+    <?= Yii::$app->cache->getOrSet("main_page_lenta_".(Yii::$app->deviceDetect->isMobile() ?"desktop":"mobile").Yii::$app->controller->action->id.$keyadd,function () {
+        $lenta = "<div id='list-wrapper' class='list-wrapper'>";
+/*
+// Фиксированные новости или банера в верху ленты
+## пример "День поля"
+*/
+
+/*		$lenta .= '<style>.lenta .list-wrapper .lenta_fix:hover{background:#60b740;}</style>
+<div class="lenta_fix"><h3>
+    <a href="/story/den_sibirskogo_polya_2023" title="День Сибирского поля-2023"><img src="/img/day_pole.svg" width="275px" height="80px" alt="День Сибирского поля"></a><div class="published_at">28-29 июня</div>
+</h3>
+</div>
+';
+*/
+        $index = 0;
+        foreach (News::findFilter()->andWhere(["(flags & 1)"=>0])->limit(70)->all() as $model){
+            $index++;
+            $lenta.= \yii\helpers\Html::tag('div',$this->render('_item_right',["model"=>$model, "index"=>$index])) ;
+
+            if($index==3)  $lenta.=$this->render("@app/views/_etc/banners/mobileMainPageLentBanner");
+            if($index==10 && Yii::$app->controller->action->id!="index") $lenta.=$this->render("@app/views/_etc/banners/desktopLentBanner");
+            if($index==20 && Yii::$app->controller->action->id!="index") $lenta.=$this->render("@app/views/_etc/banners/desktopLent20Banner");
+            if($index>20 && ($index % 10)==0 && Yii::$app->controller->action->id!="index" ) $lenta.=$this->render("@app/views/_etc/banners/desktopLent20Banner",["index"=>$index]);
+
+        }
+        $lenta.="</div>";
+        return $lenta;
+    },News::$keysCache['main_page_lenta']);
+
+    ?>
+    <div class="all-news">
+        <a href="/news">Все новости</a>
+    </div>
+</div>