<?php
/**
 * @var $this \yii\web\View
 * @var $model \app\models\News
 */

use yii\helpers\ArrayHelper;

$this->params['breadcrumbs'] = [
    [
        "text"=>"НОВОСТИ",
        "url"=>"/news"
    ]
];
$topic = ArrayHelper::getValue($model->topics,0);
if($topic instanceof \app\models\base\NewsTopic){
    $this->params['breadcrumbs'][] =
        [
            "text"=>$topic->title,
            "url"=>mb_strtoupper($topic->url)
        ];
}
Yii::$app->og->title = $topic->title;
Yii::$app->og->description = $topic->description?:'Лента подкастов - '.Yii::$app->og->description;
Yii::$app->og->og_title = $topic->title;
Yii::$app->og->og_description = Yii::$app->og->description;
$url = str_replace( '/news/', '/', $topic->getUrl(true) );
Yii::$app->og->canonical = $url

?>
<div class="row">
    <div class="col-md-8">
        <div id="post" class="post">
            <?=$this->render("/layouts/breadcrumbs")?>
            <h1><?=$model->title?></h1>
            <p class="lead"><?=$model->lid?></p>
            <p class="published_at"><?=$model->publishedAt?> <?=date("Y, H:m")?></p>
            <p>
                <?php if($model->image instanceof \app\models\base\Image):?>
                    <div class="picture-cont-16x9">
                        <picture class="w-100">
                            <source srcset="<?=$model->image->url?>" media="(min-width: 600px)">
                            <img src="<?=$model->image->url?>" alt="<?=$model->photo_title?>" class="w-100">
                        </picture>
                    </div>

                    <div class="image-title"><?=$model->photo_title?></div>
                <?php endif;?>
            </p>
            <section class="text">
                <?=$model->renderBody()?>
            </section>

        </div>
    </div>
    <script>
        (function (){
            let main_view_cont = document.getElementById('post');
            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-container">
        <?=$this->render("/layouts/lenta/lenta")?>
    </div>
</div>



