From cf77cbae6972024b85b4ba026457b67ed2f03333 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 29 Sep 2016 16:25:18 +0300 Subject: [PATCH] 14.09.16 --- frontend/config/main.php | 4 ++-- frontend/controllers/ArticlesController.php | 24 +++++++++++++++++------- frontend/views/articles/index.php | 7 ++----- frontend/views/event/_objects.php | 4 ++-- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/frontend/config/main.php b/frontend/config/main.php index 82d9287..21e835c 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -138,9 +138,9 @@ return [ 'brands' => 'catalog/brands', 'brands/' => 'catalog/brand', 'blog' => 'articles/index', - 'blog/-' => 'articles/show', + 'blog/' => 'articles/show', 'event' => 'event/index', - 'event/-' => 'event/show', + 'event/' => 'event/show', '///' => '//', '//' => '/', '/admin' => 'admin/default/index', diff --git a/frontend/controllers/ArticlesController.php b/frontend/controllers/ArticlesController.php index c6645bf..010169e 100755 --- a/frontend/controllers/ArticlesController.php +++ b/frontend/controllers/ArticlesController.php @@ -7,7 +7,7 @@ use yii\web\Controller; use common\models\Articles; use yii\web\HttpException; use yii\data\Pagination; - +use yii\web\NotFoundHttpException; class ArticlesController extends Controller { @@ -30,13 +30,23 @@ class ArticlesController extends Controller ]); } - public function actionShow(){ - if(!$news = Articles::find()->where(['id'=>$_GET['id']])->one()) - throw new HttpException(404, 'Данной странице не существует!'); + public function actionShow($translit){ + $news = $this->findModel($translit); + - return $this->render('show', [ - 'news'=>$news, - ]); + return $this->render('show', [ + 'news'=>$news, + ]); + } + + + protected function findModel($translit) + { + if (($model = Articles::findOne(["translit"=>$translit])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } } \ No newline at end of file diff --git a/frontend/views/articles/index.php b/frontend/views/articles/index.php index 9a8b535..090dc6a 100755 --- a/frontend/views/articles/index.php +++ b/frontend/views/articles/index.php @@ -39,15 +39,13 @@
imageUrl, 'list'), [ 'class' => 'float-left' ]) ?> title ?>
comments) : "Оставить отзыв" ), [ 'articles/show', 'translit' => $item->translit, - 'id' => $item->id, '#' => 'artbox-comment', ]); ?> diff --git a/frontend/views/event/_objects.php b/frontend/views/event/_objects.php index 3312857..93ff0a1 100755 --- a/frontend/views/event/_objects.php +++ b/frontend/views/event/_objects.php @@ -9,11 +9,11 @@ FlipclockAsset::register($this);