How do we defeat the URLmanager again?



  • That was the rule.

    'serials/<slug:\w*>' =>  'serial/category/list',
    'serials/<id>'   =>  'serial/category/oneserial',
    

    I write such references

    Yii::$app->urlManager->createUrl(['/serial/category/oneserial','id'=>$model->slug_serial]) //ссылка формируется такая /serials/serial-nazvanie-seriala
     Yii::$app->urlManager->createUrl(['/serial/category/list','slug'=>$ct->slug_category])//ссылка формируется такая /serials/сategory
    

    but if you add a tyre, for example /serials/nazvanie-sategory, in the target line receives serials?slug=nazvanie-category tried to decide that.

    'serials/<slug:\w*>' =>  'serial/category/list',
    'serials/<slug:[\w_\-]+>' =>  'serial/category/list',
    'serials/<id>'   =>  'serial/category/oneserial',
    

    Now, /serials/nazvanie-sategory is good, but this address /serials/serial-nazvanie-seriala now uses the second rule and passes to this address serial/category/list, which is ejected into the front page, to be honest, I don't understand why and 2 how to fix it.



  • I don't know what the question is. To get an address for the species. /serials/serial-nazvanie-seriala The rule should be:
    'serials/<slug:[\w_\-]+>' => 'serial/category/list',
    and generate:
    Yii::$app->urlManager->createUrl(['/serial/category/list','slug'=>'serial-nazvanie-seriala'])
    There's no need to make two rules.

    There you go.

    'serials/<id:\d+>' => 'serial/category/oneserial', 'serials/<slug:[\w_\-]+>' => 'serial/category/list',


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2