【发布时间】:2014-10-24 15:43:26
【问题描述】:
$config = array(
'best-url' => array(
'pattern' => '/best',
'paths' => array(
'controller' => 'cate',
'action' => 'index?cate_id=1',
),
),
'better-url' => array(
'pattern' => '/better',
'paths' => array(
'controller' => 'cate',
'action' => 'index?cate_id=2',
),
),
'cate-url' => array(
'pattern' => '/cate/index/:int',
'paths' => array(
'controller' => 'cate',
'action' => 'index',
'cate_id' => '1'
),
)
);
我有一个要求,url 映射到 cate_id 像 /best -> /cate/index?cate_id=1,/better -> /cate/index?cate_id = 2,我不知道如何配置我的路线,我已经在上面解决了,但是当我使用时我需要它自动反向路由
$url->get('for'=>'cate-url','cate_id'=>1)
它不能创建像 /best 或 /better 这样的 url。
怎么解决,谢谢。
【问题讨论】:
-
您不能在实际中传递这样的参数。动作只是动作名称。在 'best-url' 中,只需将 'cate_id' => '1' 参数添加到路径等等。