0

有没有办法整合以下 Yii URL 模式?怎么说,例如一个部分是可选的。

  '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>/<difficulty:\w+>'    =>  'recipes/index',
  '<category:.+>-rezepte/mit-<ingredient:\w+>/<effort:\d+>'                     =>  'recipes/index',
  '<category:.+>-rezepte/mit-<ingredient:\w+>'                                  =>  'recipes/index',
  '<category:.+>-rezepte'                                                       =>  'recipes/index',


  'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>/<difficulty:\w+>'    =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>/<category:\w+>/<effort:\d+>'                     =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>/<category:\w+>'                                  =>  'recipes/index',
  'rezepte-mit-<ingredient:.+>'                                                 =>  'recipes/index',
4

1 回答 1

0

根据此论坛帖子,您应该能够执行以下操作:

array(
    'recipes/index',
    'pattern' => '<category:\w+>-rezepte(/mit-<ingredient:\w+>)?(/<effort:\d+>)?(/<difficulty:\w+>)?',
),
于 2014-02-05T13:45:43.370 回答