私は次のroutes.php構成を持っています
Router::connect('/:type/:slug;:id', array(
'controller' => 'content',
'action' => 'show',
'type' => null,
'slug' => null,
'id' => null,
),
array(
'type' => '(articles|releases|answers|videos)',
'slug' => '[a-zA-Z0-9\-]+',
'id' => '[0-9]+',
'pass' => array('type', 'slug', 'id'),
));
そして私は次のURLを解析しようとしています:
/answers/effective-language-therapy-for-people;368
そして、ルーターは私を正しいコントローラーとアクションに導きますが、ダンプはそれがと$this->params
を正しく識別していないことを示しています$id
$slug
Array
(
[type] => answers
[slug] => answers
[id] => effective-language-therapy-for-people
[named] => Array
(
)
[pass] => Array
(
[0] => answers
[1] => answers
[2] => effective-language-therapy-for-people
)
[controller] => content
[action] => show
[plugin] =>
[url] => Array
(
[ext] => html
[url] => answers/effective-language-therapy-for-people;368
)
[form] => Array
(
)
)
だから-何が得られますか?私の正規表現が間違っているのか、何かが足りないアプローチなのか、それとも何ですか?何か案は?
注:私は読んだ:
- http://book.cakephp.org/view/948/Defining-Routes
- http://book.cakephp.org/view/949/Passing-parameters-to-action
更新、解決済み、動作中のバージョン
Router::connect('/:type/:slug:splitter:id', array('controller' => 'content', 'action' => 'view',), array(
'type' => 'articles|releases|answers|videos',
'slug' => '[a-zA-Z0-9\-]+',
'splitter' => '[\;\-\|]+',
'id' => '[0-9]+',
));