story.php 1.5 KB

123456789101112131415161718192021222324252627
  1. <?
  2. $topic_id = $model[0]->id;
  3. $news_query = \app\models\front\News::find()->leftJoin('story_relation t', 't.news_id = id')->andWhere(['t.topic_id'=>$topic_id])->limit(30);
  4. $newsDataProvider = new \yii\data\ActiveDataProvider(
  5. [
  6. "query"=>$news_query,
  7. "pagination" => false
  8. ]
  9. );
  10. $story = $newsDataProvider->getModels();
  11. $buf = '';
  12. foreach( $story as $a ){
  13. $buf .= "{ img: '/images/news/news/".$a['id']."_size2.jpg',";
  14. $buf .= " html: '<a href=\"/news/{$a['id']}/\"><div class=\"any\"><div class=\"text\"><span class=\"inverse header\">".trim(str_replace("'",'"',stripslashes($a['title'])))."</span><span class=\"inverse lid\">".trim(str_replace("'",'"',stripslashes($a['lid'])))."</span></div></div></a>'},";
  15. }
  16. // to do resize 1200 for longrid
  17. ?>
  18. <div class="title_001">Читайте также в сюжете: <a href="/story/<?=$model[0]->url?>"><?=$model[0]->title;?></a></div>
  19. <center><div class="fotoramast" data-width="720" data-ratio="680/383" data-max-width="100%"></div></center>
  20. <link href="/js/fotorama/fotorama.css" rel="stylesheet">
  21. <script src="/js/fotorama/fotorama.js" defer></script>
  22. <script type="text/javascript">
  23. window.addEventListener("DOMContentLoaded",function () {
  24. $('.fotoramast').fotorama({ width:'100%',maxwidth:800,thumbheight:70,thumbwidth:94, click:false,nav: false, captions: true, caption: 'overlay', allowfullscreen:'native', <?=($story[0]->id == $id)?'startindex:1,':''?>data: [ <?=str_replace('\"','"',$buf)?> ] });
  25. });
  26. </script>