<?php
/**
 * @var $this \yii\web\View
 * @var $news_query \yii\db\ActiveQuery
 */

use app\models\base\NewsTopic;
use app\modules\ldjson\jsonLD;


$page = \Yii::$app->request->get('page');
$ppage = ($page)?'-'.$page:'';
$addtpage = $page?". Страница ($page)":'';

$this->params['breadcrumbs'] = [
    [
        "text"=>"СТАТЬИ",
        "url"=>"/articles"
    ]
];


$this->title = "Лента статей: amic.ru";
Yii::$app->og->title = $this->title.$addtpage;
Yii::$app->og->description ='Лента Статей - '.Yii::$app->og->description.$addtpage;
Yii::$app->og->og_title = str_replace( '"',"&quot;", $this->title );
Yii::$app->og->og_description = str_replace( '"',"&quot;",Yii::$app->og->description);
$url =  '/articles';
Yii::$app->og->canonical = $url;
Yii::$app->og->og_type = "website";

jsonLD::addAmicORG();
$i = 1;
foreach($this->params['breadcrumbs'] as $el){
	jsonLD::addBreadcrumb($i, $el['url'], $el['text']);
	$i++;
}

?>
<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-articles",function (){
                            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]),
                                    "pagination" =>[
                                        "pageSize"=>0
                                    ],
                                ]),
                                'options' => [
                                    'tag' => "ul",
                                    'class' => 'list-wrapper',
                                    'id' => 'list-wrapper',
                                ],
                                "itemOptions"=>[
                                    "tag"=>"li"
                                ],
                                "itemView" => function($model)  {
									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}"],[]);
								},
                                "layout" => "{items}"
                            ]);
                        },600);
                    ?>
                </div>
            </div>
        </div>
        <div class="col-md-9">
            <div class="news-list">
                <?=$this->render("/layouts/breadcrumbs")?>
                <?php
                echo Yii::$app->cache->getOrSet("articles_news-".$ppage,function () use($news_query){
                    return \yii\widgets\ListView::widget([
                        "dataProvider" => new \yii\data\ActiveDataProvider([
                            "query"=>$news_query,
                            "pagination" =>[
                                "pageSize"=>20
                            ],
                        ]),
                        'options' => [
                            'tag' => "ul",
                            'class' => 'list-wrapper',
                            'id' => 'list-wrapper',
                        ],
                        "itemOptions"=>[
                            "tag"=>"li"
                        ],
                        "itemView" => "archive/_archive_item",
                        "layout" => "{items}{pager}"
                    ]);
                },600);
                ?>
            </div>
        </div>
    </div>
</div>


