ArticlesController.php 645 B

123456789101112131415161718192021
  1. <?php
  2. namespace app\controllers;
  3. use yii\web\Controller;
  4. class ArticlesController extends Controller
  5. {
  6. public function actionIndex(){
  7. $url = \Yii::$app->request->pathInfo;
  8. if( $url == 'articles/' || $url == 'article/' || $url == 'article' ){
  9. $queryString = \Yii::$app->request->queryString?'?'.\Yii::$app->request->queryString:'';
  10. $this->redirect('/articles'.$queryString, 301);
  11. return '';
  12. }
  13. $news_query = \app\models\front\News::find()->joinWith('topics t')
  14. ->groupBy('news.id')
  15. ->andFilterWhere(['news.type'=>6]);
  16. return $this->render("index",["news_query"=>$news_query]);
  17. }
  18. }