123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- /** @var yii\web\View $this */
- /** @var \yii\data\ActiveDataProvider $newsDataProvider */
- use app\models\Design;
- use app\modules\ldjson\jsonLD;
- use app\models\front\News;
- jsonLD::addAmicORG();
- jsonLD::$ld = jsonLD::$wp;
- Yii::$app->og->title = 'Новости Барнаула и Алтайского края — на сайте amic.ru ИА Амител';
- Yii::$app->og->og_title = Yii::$app->og->title;
- Yii::$app->og->canonical = '/';
- Yii::$app->og->og_description = 'Новости в Барнауле и Алтайском крае: оперативно репортажи с фото и видео. Интересные темы, эксперты, ответы на вопросы, тесты, игры.';
- Yii::$app->og->og_url = 'https://www.amic.ru';
- Yii::$app->og->og_type = 'website';
- Yii::$app->og->og_image = 'https://www.amic.ru/img/amic-logo.svg';
- $auto_news = Yii::$app->cache->get('main_auto_news');
- ?>
- <div class="site-index">
- <div class="row">
- <div class="col-md-8 " id="main-view-container">
- <?
- $keyadd = News::keyFilter();
- if ($this->beginCache('main-page-main-view-glob'.$keyadd, ['duration' => News::$keysCache['main-page-main-view-glob']])) {
- if( $auto_news || $keyadd){
- echo $this->render("index/main_view_slider",['auto'=>true]);
- }else{
- echo $this->render("index/main_view_slider",['auto'=>false]);
- }
- $this->endCache();
- }
- ?>
- </div>
- <script>
- (function (){
- let main_view_cont = document.getElementById('main-view-container');
- let height = main_view_cont.offsetHeight;
- console.log(height)
- let style = document.createElement("style");
- style.innerHTML = "#lenta-container{ max-height:"+height+"px;}";
- main_view_cont.parentNode.append(style);
- })()
- </script>
- <div class="col-md-4" id="lenta-wrapper">
- <div id="lenta-container">
- <?=$this->render("/layouts/lenta/lenta")?>
- </div>
- </div>
- </div>
- <?//$this->render("index/colorful_widget",['design'=>new Design(['id'=>1]),'newsDataProvider'=>new \yii\data\ActiveDataProvider(["query"=>News::find()])])?>
- <?
- if ($this->beginCache('MainPageBlock_' . ((Yii::$app->deviceDetect->isMobile())?"mobile":"desktop"), ['duration' => News::$keysCache['MainPageBlock']])) { //News::$keysCache['MainPageBlock']
- if( $auto_news ){
- $q = News::find()->andWhere(["(flags & 1)"=>0])->andWhere(['<>', 'id', News::getNH()->select('id')->limit(1)])->andWhere(['or',['NH'=>'Y'],['top'=>'Y']])->limit(3)->offset(3);
- }else{
- $q = \app\models\Kd::find()->andWhere(['>','order',2])->orderBy(["order"=>SORT_ASC])->limit(3);
- }
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>$q,
- "pagination" => false
- ]
- );
- $sort = $newsDataProvider->getModels();
- $ActiveNews = new \yii\data\ActiveDataProvider();
- $models = [];
- foreach( $sort as $item ){
- $models[] = \app\models\News::findOne($item->id);
- }
- $ActiveNews->setModels($models);
- ?>
- <?=$this->render("index/three_widgets",['newsDataProvider'=>$ActiveNews])?>
- <?php
- $i = 0;
- $design = Design::find()->andWhere(['active'=>'Y'])->orderBy(['order'=>SORT_ASC])->all();
- foreach ($design as $item) {
- $i++;
- if($i==3) echo $this->render('@app/views/_etc/banners/firstDesktopTransparant');
- if($i==6 && Yii::$app->deviceDetect->isMobile()) echo $this->render('@app/views/_etc/banners/bannerMobile3');
- if($i==6 && !Yii::$app->deviceDetect->isMobile()) echo $this->render('@app/views/_etc/banners/bannerDesktop3');
- /**
- * @var $item Design
- */
- switch ($item->design)
- {
- case Design::TOPIC_WIDGET:
- $pageSize = 10;
- break;
- case Design::IMAGINE_NEWS_WIDGET:
- $pageSize = 3;
- break;
- default:
- $pageSize = 4;
- }
- switch ($item->type)
- {
- case "topic":
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>News::find()->joinWith("topics t")->andWhere(["t.id"=>[$item->parent_id], "(flags & 1)"=>0]),
- "pagination" =>[
- "pageSize"=>$pageSize
- ],
- ]
- );
- $topic = \app\models\base\NewsTopic::findOne(['id'=>$item->parent_id]);
- break;
- case "tag":
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>News::find()->joinWith("tags t")->andWhere(["t.id"=>[$item->parent_id], "(flags & 1)"=>0]),
- "pagination" =>[
- "pageSize"=>$pageSize
- ],
- ]
- );
- $topic = \app\models\base\Tags::findOne(['id'=>$item->parent_id]);
- break;
- default:
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>News::find()->joinWith("stories t")->andWhere(["t.id"=>[$item->parent_id], "(flags & 1)"=>0]),
- "pagination" =>[
- "pageSize"=>$pageSize
- ],
- ]
- );
- $topic = \app\models\base\Story::findOne(['id'=>$item->parent_id]);
- break;
- }
- $view = \yii\helpers\ArrayHelper::getValue(Design::$id_to_view_map,$item->design,Design::$id_to_view_map[Design::IMAGINE_NEWS_WIDGET]);
- echo $this->render($view,['newsDataProvider'=>$newsDataProvider,"topic"=>$topic,"design" => $item]);
- }
- // if(!Yii::$app->deviceDetect->isMobile()) echo $this->render('@app/views/_etc/banners/desktopfirstPage');
- $this->endCache();
- }
- ?>
- </div>
|