Commit 84cd230a9ae90f7c672dcb57a2b41ddb2749479d
Merge branch 'master' of gitlab.artweb.com.ua:steska/clinica
Showing
5 changed files
with
60 additions
and
18 deletions
Show diff stats
frontend/components/UrlManager.php
| @@ -62,6 +62,7 @@ | @@ -62,6 +62,7 @@ | ||
| 62 | // $this->checkRedirect($request->url); | 62 | // $this->checkRedirect($request->url); |
| 63 | 63 | ||
| 64 | $request = $this->parseLanguage($request); | 64 | $request = $this->parseLanguage($request); |
| 65 | + | ||
| 65 | /** | 66 | /** |
| 66 | * @var Alias $alias | 67 | * @var Alias $alias |
| 67 | */ | 68 | */ |
| @@ -111,8 +112,11 @@ | @@ -111,8 +112,11 @@ | ||
| 111 | $params, | 112 | $params, |
| 112 | ]; | 113 | ]; |
| 113 | } | 114 | } |
| 114 | - | ||
| 115 | - return parent::parseRequest($request); | 115 | + $request=parent::parseRequest($request); |
| 116 | + $request[0]=rtrim($request[0],'/'); | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + return $request; | ||
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | /** | 122 | /** |
| @@ -122,6 +126,7 @@ | @@ -122,6 +126,7 @@ | ||
| 122 | */ | 126 | */ |
| 123 | public function createUrl($params) | 127 | public function createUrl($params) |
| 124 | { | 128 | { |
| 129 | + | ||
| 125 | if ($this->hideDefaultLanguagePrefix && ( $this->languages->getCurrent( | 130 | if ($this->hideDefaultLanguagePrefix && ( $this->languages->getCurrent( |
| 126 | )->url == $this->languages->getDefault()->url )) { | 131 | )->url == $this->languages->getDefault()->url )) { |
| 127 | $prefix = ''; | 132 | $prefix = ''; |
| @@ -136,7 +141,10 @@ | @@ -136,7 +141,10 @@ | ||
| 136 | return $prefix . '/' . $params[ 'alias' ][ 'value' ]; | 141 | return $prefix . '/' . $params[ 'alias' ][ 'value' ]; |
| 137 | } | 142 | } |
| 138 | } | 143 | } |
| 139 | - | 144 | + |
| 145 | + | ||
| 146 | + | ||
| 147 | + | ||
| 140 | return $prefix . parent::createUrl($params); | 148 | return $prefix . parent::createUrl($params); |
| 141 | } | 149 | } |
| 142 | 150 | ||
| @@ -153,7 +161,7 @@ | @@ -153,7 +161,7 @@ | ||
| 153 | if (in_array($split[ 0 ], array_keys($this->languages->getActive()))) { | 161 | if (in_array($split[ 0 ], array_keys($this->languages->getActive()))) { |
| 154 | if ($this->hideDefaultLanguagePrefix && ( $split[ 0 ] == $this->languages->getDefault()->url )) { | 162 | if ($this->hideDefaultLanguagePrefix && ( $split[ 0 ] == $this->languages->getDefault()->url )) { |
| 155 | unset($split[ 0 ]); | 163 | unset($split[ 0 ]); |
| 156 | - | 164 | + |
| 157 | \Yii::$app->response->redirect('/' . implode('/', $split), 301) | 165 | \Yii::$app->response->redirect('/' . implode('/', $split), 301) |
| 158 | ->send(); | 166 | ->send(); |
| 159 | \Yii::$app->end(); | 167 | \Yii::$app->end(); |
| @@ -188,6 +196,7 @@ | @@ -188,6 +196,7 @@ | ||
| 188 | */ | 196 | */ |
| 189 | protected function checkRedirect(string $url) | 197 | protected function checkRedirect(string $url) |
| 190 | { | 198 | { |
| 199 | + | ||
| 191 | // $redirect = Redirect::find() | 200 | // $redirect = Redirect::find() |
| 192 | // ->where( | 201 | // ->where( |
| 193 | // [ | 202 | // [ |
frontend/controllers/SiteController.php
| @@ -227,7 +227,10 @@ | @@ -227,7 +227,10 @@ | ||
| 227 | public function actionPage6(){ | 227 | public function actionPage6(){ |
| 228 | return $this->render('page6'); | 228 | return $this->render('page6'); |
| 229 | } | 229 | } |
| 230 | + | ||
| 230 | 231 | ||
| 232 | + | ||
| 233 | + # Вопрос/ответ | ||
| 231 | public function actionQuestions($service_id = null){ | 234 | public function actionQuestions($service_id = null){ |
| 232 | Language::getCurrent(); | 235 | Language::getCurrent(); |
| 233 | 236 |
frontend/helpers/Url.php
| @@ -22,9 +22,9 @@ | @@ -22,9 +22,9 @@ | ||
| 22 | $languages = \Yii::$container->get($languagesClass); | 22 | $languages = \Yii::$container->get($languagesClass); |
| 23 | 23 | ||
| 24 | $url = '/' . $languages->getCurrent()->url; | 24 | $url = '/' . $languages->getCurrent()->url; |
| 25 | - | 25 | + |
| 26 | $urlManager = \Yii::$app->urlManager; | 26 | $urlManager = \Yii::$app->urlManager; |
| 27 | - | 27 | + |
| 28 | if (( $languages->getCurrent()->id === $languages->getDefault( | 28 | if (( $languages->getCurrent()->id === $languages->getDefault( |
| 29 | )->id ) && $urlManager->hideDefaultLanguagePrefix) { | 29 | )->id ) && $urlManager->hideDefaultLanguagePrefix) { |
| 30 | $url = '/'; | 30 | $url = '/'; |
frontend/views/layouts/main.php
| @@ -79,7 +79,7 @@ | @@ -79,7 +79,7 @@ | ||
| 79 | <!DOCTYPE html > | 79 | <!DOCTYPE html > |
| 80 | <html xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html" lang="<?= \Yii::$app->language ?>"> | 80 | <html xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html" lang="<?= \Yii::$app->language ?>"> |
| 81 | <head> | 81 | <head> |
| 82 | - | 82 | + |
| 83 | <meta charset="<?= \Yii::$app->charset ?>"> | 83 | <meta charset="<?= \Yii::$app->charset ?>"> |
| 84 | <meta name="viewport" content="width=device-width"> | 84 | <meta name="viewport" content="width=device-width"> |
| 85 | <link type="image/x-icon" href="favicon.ico" rel="icon"> | 85 | <link type="image/x-icon" href="favicon.ico" rel="icon"> |
| @@ -157,8 +157,8 @@ | @@ -157,8 +157,8 @@ | ||
| 157 | </div> | 157 | </div> |
| 158 | 158 | ||
| 159 | <ul class="hidden-xs hidden-sm"> | 159 | <ul class="hidden-xs hidden-sm"> |
| 160 | - <li><a href="#" class="new"><span> <?=\Yii::t('app','Second thing')?> </span></a></li> | ||
| 161 | - <li><a href="<?=Url::to(['alias' => $aliases['{"0":"site/questions"}']])?>"><?=\Yii::t('app','Quest/Answer')?></a></li> | 160 | + <li><a href="/vtoroe-mnenie" class="new"><span> <?=\Yii::t('app','Second thing')?> </span></a></li> |
| 161 | + <li><a href="<?=(isset($aliases['{"0":"site/questions"}'])) ? Url::to(['alias' => $aliases['{"0":"site/questions"}']]) : Url::to(['site/questions'])?>"><?=\Yii::t('app','Quest/Answer')?></a></li> | ||
| 162 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks')?></a></li> | 162 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks')?></a></li> |
| 163 | </ul> | 163 | </ul> |
| 164 | <!-- --> | 164 | <!-- --> |
| @@ -199,11 +199,35 @@ | @@ -199,11 +199,35 @@ | ||
| 199 | $items[] = [ | 199 | $items[] = [ |
| 200 | 'label' => \Yii::t('app', 'Package offerings'), | 200 | 'label' => \Yii::t('app', 'Package offerings'), |
| 201 | 'url' => Url::to(['package/index']), | 201 | 'url' => Url::to(['package/index']), |
| 202 | - ] | 202 | + ]; |
| 203 | + | ||
| 204 | + # определяю, кому из итемов присвоить class="active' | ||
| 205 | + $itemKey=0; | ||
| 206 | + $test=[]; | ||
| 207 | + foreach ($items as $key => $item) | ||
| 208 | + { | ||
| 209 | + if(strpos($item['url'],\Yii::$app->request->url)!==false) | ||
| 210 | + { | ||
| 211 | + $test[$key]['label']=$item['label']; | ||
| 212 | + $test[$key]['options'] = [ 'class' => 'active' ]; | ||
| 213 | + $test[$key]['url']='/'; | ||
| 214 | + # die(var_dump($item)); | ||
| 215 | + } | ||
| 216 | + else | ||
| 217 | + { | ||
| 218 | + $test[$key]['label']=$item['label']; | ||
| 219 | + $test[$key]['url']=$item['url']; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + | ||
| 225 | + #var_dump(\Yii::$app->request->url); | ||
| 226 | + # die(var_dump($test,Url::current())); | ||
| 203 | ?> | 227 | ?> |
| 204 | <?php echo Nav::widget( | 228 | <?php echo Nav::widget( |
| 205 | [ | 229 | [ |
| 206 | - 'items' => $items, | 230 | + 'items' => $test, |
| 207 | 'activateItems' => false, | 231 | 'activateItems' => false, |
| 208 | ] | 232 | ] |
| 209 | ); ?> | 233 | ); ?> |
| @@ -265,9 +289,9 @@ | @@ -265,9 +289,9 @@ | ||
| 265 | <div class="menu-second-mob"> | 289 | <div class="menu-second-mob"> |
| 266 | <ul class="footer-menu"> | 290 | <ul class="footer-menu"> |
| 267 | 291 | ||
| 268 | - <li><a href="<?= Url::to([ 'site/contacts' ]) ?>"><?= \Yii::t('app', 'Contacts') ?></a></li> | ||
| 269 | - <li><a href="#" class="new"><span><?= \Yii::t('app', 'Second thing') ?></span></a></li> | ||
| 270 | - <li><a href="#"><?= \Yii::t('app', 'Quest/Answer') ?></a></li> | 292 | + <li><a href="<?= Url::to([ 'site/contact' ]) ?>"><?= \Yii::t('app', 'Contacts') ?></a></li> |
| 293 | + <li><a href="/vtoroe-mnenie" class="new"><span><?= \Yii::t('app', 'Second thing') ?></span></a></li> | ||
| 294 | + <li><a href="<?=Url::to(['site/questions'])?>"><?= \Yii::t('app', 'Quest/Answer') ?></a></li> | ||
| 271 | <li><a href="#"><?= \Yii::t('app', 'Callbacks') ?></a></li> | 295 | <li><a href="#"><?= \Yii::t('app', 'Callbacks') ?></a></li> |
| 272 | </ul> | 296 | </ul> |
| 273 | </div> | 297 | </div> |
| @@ -351,9 +375,9 @@ | @@ -351,9 +375,9 @@ | ||
| 351 | <div class="col-xs-9 col-sm-2"> | 375 | <div class="col-xs-9 col-sm-2"> |
| 352 | <ul class="footer-menu"> | 376 | <ul class="footer-menu"> |
| 353 | <li><a href="<?=Url::to(['site/about'])?>"><?=\Yii::t('app','About us')?></a></li> | 377 | <li><a href="<?=Url::to(['site/about'])?>"><?=\Yii::t('app','About us')?></a></li> |
| 354 | - <li><a href="#" ><?=\Yii::t('app','Contacts');?></a></li> | ||
| 355 | - <li><a href="<?=Url::to(['site/questions'])?>" class="new"><span><?=\Yii::t('app','Second thing');?></span></a></li> | ||
| 356 | - <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Quest/Answer');?></a></li> | 378 | + <li><a href="<?= Url::to([ 'site/contact' ]);?>" ><?=\Yii::t('app','Contacts');?></a></li> |
| 379 | + <li><a href="/vtoroe-mnenie" class="new"><span><?=\Yii::t('app','Second thing');?></span></a></li> | ||
| 380 | + <li><a href="<?=Url::to(['site/questions'])?>"><?=\Yii::t('app','Quest/Answer');?></a></li> | ||
| 357 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks');?></a></li> | 381 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks');?></a></li> |
| 358 | </ul> | 382 | </ul> |
| 359 | </div> | 383 | </div> |
frontend/views/service/view.php
| @@ -63,7 +63,13 @@ | @@ -63,7 +63,13 @@ | ||
| 63 | if (($model->id == $service->id or $model->parent_id == $service->id) and !empty($service->services)) {?> | 63 | if (($model->id == $service->id or $model->parent_id == $service->id) and !empty($service->services)) {?> |
| 64 | <ul> | 64 | <ul> |
| 65 | <?php foreach ($service->services as $item){?> | 65 | <?php foreach ($service->services as $item){?> |
| 66 | - <li class="<?=($model->id == $item->id ? 'active' : '')?>"><a href="<?=Url::to(['alias' => $item->language->alias])?>"><?=$item->title?></a></li> | 66 | + <?php if($model->id == $item->id) : ?> |
| 67 | + <li class="active"><a ><?=$item->title?></a></li> | ||
| 68 | + | ||
| 69 | + <?php else: ?> | ||
| 70 | + <li class=""><a href="<?=Url::to(['alias' => $item->language->alias])?>"><?=$item->title?></a></li> | ||
| 71 | + <?php endif;?> | ||
| 72 | + | ||
| 67 | <?php }?> | 73 | <?php }?> |
| 68 | </ul> | 74 | </ul> |
| 69 | <?php } ?> | 75 | <?php } ?> |