view.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @var $this \yii\web\View
  4. * @var $model \app\models\News
  5. */
  6. use yii\helpers\ArrayHelper;
  7. $this->params['breadcrumbs'] = [
  8. [
  9. "text"=>"НОВОСТИ",
  10. "url"=>"/news"
  11. ]
  12. ];
  13. $topic = ArrayHelper::getValue($model->topics,0);
  14. if($topic instanceof \app\models\base\NewsTopic){
  15. $this->params['breadcrumbs'][] =
  16. [
  17. "text"=>$topic->title,
  18. "url"=>mb_strtoupper($topic->url)
  19. ];
  20. }
  21. Yii::$app->og->title = $topic->title;
  22. Yii::$app->og->description = $topic->description?:'Лента подкастов - '.Yii::$app->og->description;
  23. Yii::$app->og->og_title = $topic->title;
  24. Yii::$app->og->og_description = Yii::$app->og->description;
  25. $url = str_replace( '/news/', '/', $topic->getUrl(true) );
  26. Yii::$app->og->canonical = $url
  27. ?>
  28. <div class="row">
  29. <div class="col-md-8">
  30. <div id="post" class="post">
  31. <?=$this->render("/layouts/breadcrumbs")?>
  32. <h1><?=$model->title?></h1>
  33. <p class="lead"><?=$model->lid?></p>
  34. <p class="published_at"><?=$model->publishedAt?> <?=date("Y, H:m")?></p>
  35. <p>
  36. <?php if($model->image instanceof \app\models\base\Image):?>
  37. <div class="picture-cont-16x9">
  38. <picture class="w-100">
  39. <source srcset="<?=$model->image->url?>" media="(min-width: 600px)">
  40. <img src="<?=$model->image->url?>" alt="<?=$model->photo_title?>" class="w-100">
  41. </picture>
  42. </div>
  43. <div class="image-title"><?=$model->photo_title?></div>
  44. <?php endif;?>
  45. </p>
  46. <section class="text">
  47. <?=$model->renderBody()?>
  48. </section>
  49. </div>
  50. </div>
  51. <script>
  52. (function (){
  53. let main_view_cont = document.getElementById('post');
  54. let height = main_view_cont.offsetHeight;
  55. console.log(height)
  56. let style = document.createElement("style");
  57. style.innerHTML = "#lenta-container{ max-height:"+height+"px;}";
  58. main_view_cont.parentNode.append(style);
  59. })()
  60. </script>
  61. <div class="col-md-4" id="lenta-container">
  62. <?=$this->render("/layouts/lenta/lenta")?>
  63. </div>
  64. </div>