12345678910111213141516171819202122232425 |
- <?php
- namespace app\controllers;
- use yii\web\Controller;
- class ArticlesController extends Controller
- {
- public function actionIndex(){
- $url = \Yii::$app->request->pathInfo;
- if( $url == 'articles/' || $url == 'article/' || $url == 'article' ){
- $queryString = \Yii::$app->request->queryString?'?'.\Yii::$app->request->queryString:'';
- $this->redirect('/articles'.$queryString, 301);
- return '';
- }
- $news_query = \app\models\front\News::find()->joinWith('topics t')
- ->groupBy('news.id')
- ->andFilterWhere(['news.type'=>6]);
- return $this->render("index",["news_query"=>$news_query]);
- }
- public function actionView(int $id):string {
- $this->redirect('/news/'.$id, 301);
- return '';
- }
- }
|