\app\models\News::getMainView()->orderBy(["dt_pub"=>SORT_DESC])->limit(3), "pagination" =>[ "pageSize"=>4 ], ] ); */ $NHDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>News::getNH()->limit(1), "pagination" => false ] ); $NH = $NHDataProvider->getModels(); $newsDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\Kd::find()->orderBy(["order"=>SORT_ASC])->limit(3), "pagination" => false ] ); $sort = $newsDataProvider->getModels(); $news = new \yii\data\ActiveDataProvider(); $models = []; if($NH[0] instanceof \app\models\front\News) $models[] = $NH[0] ; //$models[] = \app\models\News::findOne($NH[0]->id); foreach( $sort as $item ){ $model = News::findOne($item->id); if($model instanceof \app\models\front\News) $models[] = $model; } $news->setModels($models); echo \yii\helpers\Html::beginTag("div",["class"=>"main-view"]); echo Yii::$app->cache->getOrSet("main-page-main-view",function () use ($news){ return \yii\widgets\ListView::widget([ "dataProvider" => $news, 'options' => [ 'tag' => false, 'class' => 'list-wrapper', 'id' => 'list-wrapper', ], "itemOptions"=>[ "tag"=>false ], "itemView" => "_main_view_item", "layout" => "{items}" ]); },News::$keysCache['main-page-main-view']); echo \yii\helpers\Html::endTag("div");