1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- use \app\models\News;
- use \app\models\base\Kd;
- use app\models\base\Image;
- $NHDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>\app\models\News::getNH()->limit(1),
- "pagination" => false
- ]
- );
- //print_a($NHDataProvider->query->createCommand()->rawSQL);
- $NH = $NHDataProvider->getModels();
- $newsDataProvider = new \yii\data\ActiveDataProvider(
- [
- "query"=>$model->find()->select('*')->leftJoin( 'news', 'news.id = kd.id')->where(['news.active'=>'Y'])->andWhere(['between', 'news.dt_pub', date("Y-m-d H:i:00",time()-2678400*12 ) , date("Y-m-d H:i:00")])->orderBy(["kd.order"=>SORT_ASC])->limit(6),
- "pagination" => false
- ]
- );
- $sort = $newsDataProvider->getModels();
- //print_a($newsDataProvider->query->createCommand()->rawSQL);
- $news = new \yii\data\ActiveDataProvider();
- $models = [];
- $models[] = $NH[0];//News::findOne($NH[0]->id);
- foreach( $sort as $item ){
- $models[] = News::findOne($item->id);
- }
- $news->setModels($models);
- Yii::$app->cache->delete('main-page-main-view');
- Yii::$app->cache->delete('MainPageBlock');
- echo \yii\helpers\Html::beginTag("div",["class"=>"main-view"]);
- echo \yii\widgets\ListView::widget([
- "dataProvider" => $news,
- 'options' => [
- 'tag' => false,
- 'class' => 'list-wrapper',
- 'id' => 'list-wrapper',
- ],
- "itemOptions"=>[
- "tag"=>false
- ],
- "itemView" => "@app/views/site/index/_main_view_item",
- "layout" => "{items}"
- ]);
|