Answer the question
In order to leave comments, you need to log in
How to set URL for posts in yii2?
The following URLs are obtained from the code below => site.ru/blog/1/
How to replace 1 with TEXT?
//мой маршруизатор
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
// 'enableStrictParsing' => true,
'suffix' => '/',
'rules' => [
''=>'site/index',
'<module:\w+>/<id:\d+>' => '/<module>/default/view',
'<action:\w+>'=>'site/<action>',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
]
// ...
],
// вывожу страницы
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
Answer the question
In order to leave comments, you need to log in
Implement your own class of rules that will replace the id-shku with the alias specified in the article
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question