\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(4),
"pagination" => false
]
);
$NH = $NHDataProvider->getModels();
$arrayNH = [];
foreach( $NH as $item ){
$arrayNH[] = $item->id;
}
if( $auto ){
$newsDataProvider = new \yii\data\ActiveDataProvider(
[
"query"=>News::findFilter()->andWhere(["(flags & 1)"=>0])->andWhere(['not',[ 'id' => $arrayNH]])->andWhere(['or',['NH'=>'Y'],['top'=>'Y']])->limit(3),
"pagination" => false
]
);
}else{
$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] ;
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\helpers\Html::beginTag('div',['id'=>"top_mslider","class"=>""]);
if(count($NH)>1){
echo \yii\helpers\Html::beginTag('div',['class'=>'arrows']);
echo \yii\helpers\Html::tag('div','',['class'=>"prev"]);
echo \yii\helpers\Html::tag('div','',['class'=>"next"]);
echo \yii\helpers\Html::endTag('div');
}
echo \yii\helpers\Html::beginTag('div',["class"=>"slides"]);
echo Yii::$app->cache->getOrSet("main-page-main-views",function () use ($NHDataProvider,$NH){
return \yii\widgets\ListView::widget([
"dataProvider" => $NHDataProvider,
'options' => [
'tag' => false,
'class' => 'list-wrapper',
'id' => 'list-wrapper',
],
"itemOptions"=>[
"tag"=>false
],
'viewParams' => [
'elcount' => count($NH)
],
"itemView" => "_main_view_item_slider",
"layout" => "{items}"
]);
},News::$keysCache['main-page-main-view']);
echo \yii\helpers\Html::endTag('div');
?>
echo \yii\helpers\Html::endTag('div');
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_pod",
"layout" => "{items}"
]);
},News::$keysCache['main-page-main-view']);
echo \yii\helpers\Html::endTag("div");
echo \yii\helpers\Html::endTag("div");
?>