Answer the question
In order to leave comments, you need to log in
Yii2 link generation error (Yii2 and multilingual organization) how to fix?
Good afternoon, after reading and applying to my project the article described on Habré (Yii2 and multilingual organization) , I had the following problem when configuring
/frontend/config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'class'=>'frontend\components\LangUrlManager',
'rules'=>[
'/' => 'site/index',
'<controller:\w+>/<action:\w+>/*'=>'<controller>/<action>',
'shop/view/<id:[\d]+>' =>'site/view',
'shop/category/<category_url:[\w_-]+>/<id:[\d]+>'=>'site/view',
'shop/category/<category_url:[\w_-]+>'=>'site/category',
]
],
<?php echo Html::a("Подробнее", ['shop/view', 'id' => $item->id], ['class' => "btn btn-default"]); ?>
$url = str_replace("*", "", $url);
if($params['id']){
$url = str_replace("?id=", '', $url);
}
Answer the question
In order to leave comments, you need to log in
Most likely, the problem is in the priority of the rules in the config.
is located before
and therefore it is used when forming a link.
I.e,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'class'=>'frontend\components\LangUrlManager',
'rules'=>[
'/' => 'site/index',
'shop/view/<id:[\d]+>' =>'site/view',
'shop/category/<category_url:[\w_-]+>/<id:[\d]+>'=>'site/view',
'shop/category/<category_url:[\w_-]+>'=>'site/category',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
]
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question