<?php
/**
 * @var $this \yii\web\View
 * @var $topic_id integer
 */

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

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

$topic = NewsTopic::find()->andWhere(['id'=>$topic_id])->one();
$url = str_replace( '/news/', '/video/', $topic->getUrl(true) );

$this->params['breadcrumbs'] = [
    [
        "text"=>"Видео.amic",
        "url"=>"/video"
    ]
];

$this->params['breadcrumbs'][] =
	[
		"text"=>$topic->title,
		"url"=>"/video/".$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 = str_replace( '"',"&quot;",$topic->title);
Yii::$app->og->og_description = str_replace( '"',"&quot;",Yii::$app->og->description);
$url = str_replace( '/news/', '/', $topic->getUrl(true) );
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="podcasts">
    <h1><?=$this->title?></h1>
    <div class="row">
        <div class="col-md-12">
            <?php foreach (NewsTopic::find()->andWhere(["show"=>"Y","active"=>1,'topic_id'=>$topic_id])->orderBy(["order"=>SORT_ASC])->all() as $topic): /** @var $topic NewsTopic */?>
                <div class="topic_item">
                    <h2 class="topic_title">
                        <a href="/video/<?=$topic->url?>" title="<?=$topic->title?>"><?=$topic->title?></a>
                        <a href="/video/<?=$topic->url?>" title="<?=$topic->title?>">
                            <div class="video-list-title-link">
                                <svg class="icon icon-play">
                                    <use xlink:href="/svg/symbol/sprite-styled.svg#play"></use>
                                </svg>
                            </div>
                        </a>
                    </h2>
                    <div class="topic_items row">
                        <?php
                        $news = $topic->getNews()->limit(3)->all();
                        foreach ($news as $post){ /** @var $post \app\models\front\News */
                            echo $this->render('archive/_archive_item',["model"=>$post]);
                        }
                        ?>
                    </div>
                </div>
            <?php endforeach;?>
        </div>
    </div>
</div>


