diff --git a/frontend/components/UrlManager.php b/frontend/components/UrlManager.php index 26faa46..b55f706 100644 --- a/frontend/components/UrlManager.php +++ b/frontend/components/UrlManager.php @@ -62,6 +62,7 @@ // $this->checkRedirect($request->url); $request = $this->parseLanguage($request); + /** * @var Alias $alias */ @@ -111,8 +112,11 @@ $params, ]; } - - return parent::parseRequest($request); + $request=parent::parseRequest($request); + $request[0]=rtrim($request[0],'/'); + + + return $request; } /** @@ -122,6 +126,7 @@ */ public function createUrl($params) { + if ($this->hideDefaultLanguagePrefix && ( $this->languages->getCurrent( )->url == $this->languages->getDefault()->url )) { $prefix = ''; @@ -136,7 +141,10 @@ return $prefix . '/' . $params[ 'alias' ][ 'value' ]; } } - + + + + return $prefix . parent::createUrl($params); } @@ -153,7 +161,7 @@ if (in_array($split[ 0 ], array_keys($this->languages->getActive()))) { if ($this->hideDefaultLanguagePrefix && ( $split[ 0 ] == $this->languages->getDefault()->url )) { unset($split[ 0 ]); - + \Yii::$app->response->redirect('/' . implode('/', $split), 301) ->send(); \Yii::$app->end(); @@ -188,6 +196,7 @@ */ protected function checkRedirect(string $url) { + // $redirect = Redirect::find() // ->where( // [ diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index b710736..6f0d119 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -227,7 +227,10 @@ public function actionPage6(){ return $this->render('page6'); } + + + # Вопрос/ответ public function actionQuestions($service_id = null){ Language::getCurrent(); diff --git a/frontend/helpers/Url.php b/frontend/helpers/Url.php index 1784edf..1bdd8ae 100644 --- a/frontend/helpers/Url.php +++ b/frontend/helpers/Url.php @@ -22,9 +22,9 @@ $languages = \Yii::$container->get($languagesClass); $url = '/' . $languages->getCurrent()->url; - + $urlManager = \Yii::$app->urlManager; - + if (( $languages->getCurrent()->id === $languages->getDefault( )->id ) && $urlManager->hideDefaultLanguagePrefix) { $url = '/'; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 19e13ac..1dfbc51 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -79,7 +79,7 @@ - + @@ -157,8 +157,8 @@ @@ -199,11 +199,35 @@ $items[] = [ 'label' => \Yii::t('app', 'Package offerings'), 'url' => Url::to(['package/index']), - ] + ]; + + # определяю, кому из итемов присвоить class="active' + $itemKey=0; + $test=[]; + foreach ($items as $key => $item) + { + if(strpos($item['url'],\Yii::$app->request->url)!==false) + { + $test[$key]['label']=$item['label']; + $test[$key]['options'] = [ 'class' => 'active' ]; + $test[$key]['url']='/'; + # die(var_dump($item)); + } + else + { + $test[$key]['label']=$item['label']; + $test[$key]['url']=$item['url']; + } + + } + + + #var_dump(\Yii::$app->request->url); + # die(var_dump($test,Url::current())); ?> $items, + 'items' => $test, 'activateItems' => false, ] ); ?> @@ -265,9 +289,9 @@ @@ -351,9 +375,9 @@
diff --git a/frontend/views/service/view.php b/frontend/views/service/view.php index 1e7b970..f270e3a 100644 --- a/frontend/views/service/view.php +++ b/frontend/views/service/view.php @@ -63,7 +63,13 @@ if (($model->id == $service->id or $model->parent_id == $service->id) and !empty($service->services)) {?> -- libgit2 0.21.4