\app\models\News::getMainView()->orderBy(["dt_pub"=>SORT_DESC])->limit(3), "pagination" =>[ "pageSize"=>4 ], ] ); */ $keyadd = News::keyFilter(); $NHDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>News::getNH()->limit(1), "pagination" => false ] ); $NH = $NHDataProvider->getModels(); $newsDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>News::findFilter()->andWhere(["(flags & 1)"=>0])->andWhere(['<>', 'id', $NH[0]->id])->andWhere(['or',['NH'=>'Y'],['top'=>'Y']])->limit(3), "pagination" => false ] ); $sort = $newsDataProvider->getModels(); $news = new \yii\data\ActiveDataProvider(); $models = []; if($NH[0] instanceof \app\models\front\News) $models[] = $NH[0] ; 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-$keyadd",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");