title="Новости"; //тест (заменить на новостьи дня и по календарику) /* $newsDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\News::getMainView()->orderBy(["dt_pub"=>SORT_DESC])->limit(50), "pagination" =>[ "pageSize"=>50 ], ] ); */ $b_date = date("Y-m-d 00:00:00",time()-60*60*24*5); $e_date = date("3000-m-d 23:59:59"); $tnow = date("Y-m-d H:i:s"); //\app\models\base\News::find()->andwhere(['between', 'dt_pub', $b_date , $e_date])->orwhere(['active'=>'N'])->orderBy(["dt_pub"=>SORT_DESC])->limit(200) //echo "SELECT * FROM `news` WHERE (`dt_pub` between '$b_date' and '$e_date' and `active`='N') or (`dt_pub` > '$tnow' and `active`='Y')"; exit; $newsDataProvider = new \yii\data\ActiveDataProvider( [ "query"=>\app\models\base\News::findBySql("SELECT * FROM `news` FORCE INDEX(`calendar`) WHERE (`dt_pub` between '$b_date' and '$e_date' and `active`='N') or (`dt_pub` > '$tnow' and `active`='Y') order by `dt_pub` DESC"), "pagination" =>[ "pageSize"=>200 ], ] ); $cache = Yii::$app->cache; /**** ****/ ?>
getModels() as $item ){ // print_r($item->getTopics()); $strTopics = ''; $NewsItem[] = $item->id; foreach( $item->getTopics()->primaryModel->topics as $topic ){ $strTopics = $strTopics." [".$topic->title."]"; } $strbage = ''; if( $item->verifed == 'Y' ) $strbage .= 'проверено
'; if( $item->top == 'Y' ) $strbage .= 'картина дня
'; if( $item->NH == 'Y' ) $strbage .= 'НЧ
'; if( $item->comments == 'N' ) $strbage .= 'no comments
'; if( ($item->flags & 1) == 1 ) $strbage .= 'без главной
'; if( $res = $cache->get("editNews_".$item->id) ){ $strbage .= ''.unserialize($res)['author'].'
'; } $show = ($item->active == 'N' || strtotime($item->dt_pub) > time())?'preview/'.$item->uid:$item->id; $author = Authors::getAuthor($item->author); $icon = $item->getImage()->getIcon(); ?> active == 'N')?' class="table-secondary"':''?>> // print_r($item); // ?>
время фото заголовок статусы управление
dt_pub))?> title?>

editors)?>
name?>
КДНЧuser->can('deleteNews')){?>
"+value+""); console.log(key); }); } } ); } JS; $this->registerJs( $script,View::POS_READY); //print_r($newsDataProvider->getModels());