story.php 1.4 KB

12345678910111213141516171819202122232425262728
  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. $c = Yii::$app->acache;
  18. $c->set('fotorama', true);
  19. ?>
  20. <div class="title_001">Читайте также в сюжете: <a href="/story/<?=$model[0]->url?>"><?=$model[0]->title;?></a></div>
  21. <center><div class="fotoramast" data-width="720" data-ratio="680/383" data-max-width="100%"></div></center>
  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>