我现在正在使用一个应用程序,其中包含一些涉及传递args的非常奇怪的路由。一切正常,除分页外,链接正确反向路由。我正在撕扯我的头发,但必须遗漏一些东西。
我的路线是:
Router::connect('/manufacturer/:manufacturer/:friendly0', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0')));
Router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1')));
Router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1/:friendly2', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1', 'friendly2')));
Router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1/:friendly2/:friendly3', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1', 'friendly2', 'friendly3')));
Router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1/:friendly2/:friendly3/:friendly4', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1', 'friendly2', 'friendly3', 'friendly4')));
我已将传递的args添加到Paginator选项中,如下所示:
$this->Paginator->options(array('url'=>array(
'controller' => 'categories',
'action' => 'view',
'manufacturer' => 'nsm',
'friendly0' => 'Accessories'
)));
但是,分页符链接如下:
/类别/视图/页:2 /制造商:NSM / friendly0:附件
他们应该是:
/制造商/ NSM /附件/页:2
有人可以帮忙吗?
提前致谢。
编辑:
如果我在每条路线的末尾添加/ *,那么分页链接和常规链接按预期工作,但仅适用于第一条路线。我猜测,在派遣期间其他路线应该匹配时,由于/*,第一条路线始终为真。
有趣的是,如果我改变这些路线的顺序如下:
Router::connect('/manufacturer/:manufacturer/:friendly0/:friendly1/*', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0', 'friendly1')));
Router::connect('/manufacturer/:manufacturer/:friendly0/*', array('controller'=>'categories', 'action'=>'view'), array('pass'=>array('manufacturer', 'friendly0')));
然后,Cake似乎认为页面:2名为param的应该是传递的arg并将其传递给友好的:1。