Answer the question
In order to leave comments, you need to log in
How to change yii2 Get request via urlmanager?
Hello.
You need to change the type of get request to the controller function. There is a controller and an actionSay function
public function actionSay($message="Hello world"){
return $this->render('say',['messager'=>$message,'meta'=>'METATEST']);
}
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName'=>false,
'enableStrictParsing' => true,
// 'class' => 'yii\web\UrlManager',
'rules' => [
'<action>'=>'site/<action>',
'' => 'site/index',
],
// ...
],
Answer the question
In order to leave comments, you need to log in
In config:
'rules' => [
'' => 'site/index', // можно убрать и задать 'defaultRoute' => 'site/index' в конфиге
'say/<message>' => 'site/say',
//'say/message/<message>' => 'site/say',
],
public function actionSay($message) // не уверен насчет задания значения по умолчанию, надо Вам проверить
{
return $this->render('say', ['messager' => $message, 'meta' => 'METATEST']);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question