12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * @var \yii\web\View $this
- * @var $post \app\models\News
- * @var \yii\data\ActiveDataProvider $newsDataProvider
- * @var \app\models\base\NewsTopic | \app\models\base\Story $topic
- */
- use app\models\News;
- $view = $this;
- echo \yii\helpers\Html::beginTag("div",["class"=>"partner-news row"]);
- echo Yii::$app->cache->getOrSet("main-page-third-row-l2",function () use ($newsDataProvider,$view){
- $result = "";
- $sliderItems = \app\models\front\TopSlider::find()
- ->andWhere(['<','published_from',date("Y-m-d H:i:s")])
- ->andWhere(['>','published_to',date("Y-m-d H:i:s")])
- ->andWhere(['is_active'=>1])->all();
- $k=0;
- foreach ($newsDataProvider->getModels() as $post)
- {
- if($k>=2 && count($sliderItems)>0) continue;
- $k++;
- $result.= $view->render('_partner_news_item',["model"=>$post,"key"=>$k]);
- }
- try {
- $result .= "<!-- slider -->\n";
- $result.= $view->render('_three_widgets_slider',['models'=>$sliderItems]);
- } catch (Exception $e) {
- // var_dump($e);
- }
- return $result;
- },60);
- echo \yii\helpers\Html::endTag("div");
|