S
S
Sergey Beloventsev2016-08-17 15:50:04
Yii
Sergey Beloventsev, 2016-08-17 15:50:04

Incomprehensible value when routing, how to find out where the error comes from?

here is the url

http://film.lc/serial/category/oneserial?id=serial-Bekstrom

do this
frontend/config/main
'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'rules' => [
                            [
                                 'class' => 'frontend\components\FilmUrlRule',
                            ],
                ],

frontend\components\FilmUrlRule
class FilmUrlRule extends Object implements UrlRuleInterface
    {
     public function createUrl($manager, $route, $params)
        {
            var_dump($route);
            var_dump($params);
    }
     public function parseRequest($manager, $request)
        {        return false;
        }
    }

I get the following value of var_dump why and how to understand where the routing error is?
string(19) "serial/category/all" array(0) { }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-08-18
@Sergalas

1. Your parseRequest returns false, which is what you expect from this code.
2. Why did the class appear in the rules
3. Why did it become necessary to create a class and override the standard one, why not do what you want with standard methods?

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
'serial/category/oneserial' => 'mySomeController/myaction' 
            ],
],

Inside mySomeController:
public function actionMyaction($id){
echo $id;
}

or if serial and category are variables
'rules' => [
'<serial>/<category>/oneserial' => 'mySomeController/myaction' 
            ],

Inside mySomeController:
public function actionMyaction($id,$serial,$category){
echo $id;
echo $serial;
echo $category;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question