<?php
/**
 * @var $this \yii\web\View
 * @var $topic NewsTopic
 */

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

$page = \Yii::$app->request->get('page');
$addtpage = $page?". Страница ($page)":'';
$url = str_replace( '/news/', '/podcasts/', $topic->getUrl(true) );

$this->params['breadcrumbs'] = [
    [
        "text"=>"Подкасты",
        "url"=>"/podcasts"
    ]
];

$this->params['breadcrumbs'][] =
	[
		"text"=>$topic->title,
		"url"=>"/podcasts/".$url
	];
$this->title = $topic->title;
Yii::$app->og->title =$topic->title.$addtpage;
Yii::$app->og->description =$topic->description?:'Лента подкастов - '.Yii::$app->og->description.$addtpage;
Yii::$app->og->og_title = strip_tags(str_replace( '"',"&quot;",$topic->title));
Yii::$app->og->og_description = strip_tags(str_replace( '"',"&quot;",Yii::$app->og->description));
Yii::$app->og->canonical = $url;
Yii::$app->og->og_url = $url;
if( file_exists(\Yii::getAlias('@webroot').$topic->image->url) ){
	Yii::$app->og->og_image = $topic->image->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="podcasts">
    <h1><?=$topic->title?></h1>
    <div class="row">
        <div class="col-md-12">
            <div class="topic_item">
                <div class="topic_items row">
                    <?php
                    echo  \yii\widgets\ListView::widget([
                        "dataProvider" => new \yii\data\ActiveDataProvider([
                            "query"=>$topic->getNews(),
                            "pagination" =>[
                                "pageSize"=>21
                            ],
                        ]),
                        'options' => [
                            'tag' => NULL,
                        ],
                        "itemOptions"=>[
                            "tag"=>NULL
                        ],
                        "itemView" => "_archive_item",
                        "layout" => "{items}{pager}"
                    ]);
                    ?>
                </div>
            </div>
        </div>
    </div>
</div>


