"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 .= "\n"; $result.= $view->render('_three_widgets_slider',['models'=>$sliderItems]); } catch (Exception $e) { // var_dump($e); } return $result; },60); echo \yii\helpers\Html::endTag("div");