123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- /**
- * @var $topic NewsTopic | NULL
- * @var $this \yii\web\View
- * @var $news_query \yii\db\ActiveQuery
- */
- use app\models\base\NewsTopic;
- use app\models\base\Story;
- use app\models\base\Tags;
- use yii\widgets\ListView;
- use yii\helpers\Url;
- $this->params['breadcrumbs'] = [
- [
- "text"=>"НОВОСТИ",
- "url"=>"/news"
- ]
- ];
- $page = \Yii::$app->request->get('page');
- $addpage = $page?'?page='.$page:'';
- $addtpage = $page?". Страница ($page)":'';
- if($topic instanceof NewsTopic || $topic instanceof Story || $topic instanceof Tags){
- $this->params['breadcrumbs'][] =
- [
- "text"=>$topic->title,
- "url"=>$topic->url
- ];
- $addtitle = ( $topic instanceof Tags )?'Тег: ':'';
- // $addtitle = ( $topic instanceof Story )?'Сюэет: ':''; открыть если будут дубли
- Yii::$app->og->canonical = $topic->getUrl(true);
- $this->title = $topic->title;
- Yii::$app->og->title = $addtitle.$topic->title.$addtpage;
- Yii::$app->og->description = $topic->description?:'Лента новостей - '.Yii::$app->og->description.$addtpage;
- Yii::$app->og->og_title = str_replace( '"',""",$topic->title);
- Yii::$app->og->og_description = str_replace( '"', """, Yii::$app->og->description );
- }else{
- Yii::$app->og->title = 'Лента новостей - '.Yii::$app->og->title.$addtpage;
- Yii::$app->og->description = 'Лента новостей - '.Yii::$app->og->description.$addtpage;
- Yii::$app->og->og_title = str_replace( '"',""", Yii::$app->og->title );
- Yii::$app->og->og_description = str_replace( '"',""", Yii::$app->og->description );
- Yii::$app->og->canonical = Url::base('https')."/news".$addpage;
- }
- //$pages->setPageSize(0,true);
- ?>
- <div class="archive">
- <div class="row">
- <div class="col-md-3">
- <div class="topics-list">
- <div class="topics-continer">
- <?php
- echo Yii::$app->cache->getOrSet("archive_rubrics-{$topic->id}",function () use($topic){
- return \yii\widgets\ListView::widget([
- "dataProvider" => new \yii\data\ActiveDataProvider([
- "query"=>NewsTopic::find()->andWhere(["show"=>"Y","active"=>1,"topic_id"=>null])->orderBy(["order"=>SORT_ASC]), //"topic_id"=>$topic->id next lavel maybe
- "pagination" =>[
- "pageSize"=>0
- ],
- ]),
- 'options' => [
- 'tag' => "ul",
- 'class' => 'list-wrapper',
- 'id' => 'list-wrapper',
- ],
- "itemOptions"=>[
- "tag"=>"li"
- ],
- "itemView" => function($model) use($topic) {
- if( $model->url == '----'){
- $ret = \yii\helpers\Html::tag('div','',['class' => ['hr']]);
- $ret .= \yii\helpers\Html::tag('span',$model->title,['class' => ['header']]);
- return $ret;
- }
- return \yii\helpers\Html::a($model->title,["news/{$model->url}"],['class'=>$model->id==$topic->id?"active":""]);
- },
- "layout" => "{items}"
- ]);
- },NewsTopic::$keysCache['archive_rubrics-##']);
- ?>
- </div>
- </div>
- </div>
- <div class="col-md-9">
- <div class="news-list">
- <?=$this->render("/layouts/breadcrumbs")?>
- <?=$this->render("archive/filters")?>
- <?php
- $adkey = ($topic instanceof Story)?'Story-':'';
- $adkey =$adkey.($keycahe ?? '');
- $request = Yii::$app->request;
- $ppage = $request->get('page');
- $ppage = ($ppage)?'-'.$ppage:'';
- $daterange = $request->get('daterange');
- $dr = ($daterange)?'-'.$daterange:'';
- echo Yii::$app->cache->getOrSet("archive_news-{$adkey}{$dr}{$topic->id}{$ppage}",function () use($news_query, $pages){
- return ListView::widget([
- "dataProvider" => new \yii\data\ActiveDataProvider([
- "query"=>$news_query,
- "pagination"=>$pages,
- "totalCount"=>$pages->totalCount,
- ]),
- 'options' => [
- 'tag' => "ul",
- 'class' => 'list-wrapper',
- 'id' => 'list-wrapper',
- ],
- "itemOptions"=>[
- "tag"=>"li"
- ],
- "itemView" => "archive/_archive_item",
- "layout" => "{items}{pager}"
- ]);
- },NewsTopic::$keysCache['archive_news-##']);
- ?>
- </div>
- </div>
- </div>
- </div>
|