kohana 3控制器操作参数的路由问题
我在模块的 init.php 中定义了此路由;
Route::set('store', 'store/<store_id>(/<controller>(/<action>(/<id>)))',
array(
'store_id' => '\d+'
))
->defaults(array(
'controller' => 'main',
'action' => 'index',
));
并且 bootstrap.php 中的默认路由仍然完好无损。
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
我的 Controller_Item 类;
class Controller_Item extends Controller {
function action_category($category_id)
{
echo 'Category ID: '.$category_id;
}
}
使用http://mydomain.com/item/category/8
输出:
Category ID: 8
they point to correct routing which was;Controller_Item and method action_category(8)
问题是当使用修改后的路线时; http://mydomain.com/store/1/item/category/8
输出:
Category ID: 1
it become action_category(1) (it takes the parameter from <store_id>)I have this routing defined in my module's init.php;
Route::set('store', 'store/<store_id>(/<controller>(/<action>(/<id>)))',
array(
'store_id' => '\d+'
))
->defaults(array(
'controller' => 'main',
'action' => 'index',
));
and the default route in bootstrap.php is still intact.
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
my Controller_Item class;
class Controller_Item extends Controller {
function action_category($category_id)
{
echo 'Category ID: '.$category_id;
}
}
Using http://mydomain.com/item/category/8
Output:
Category ID: 8
they point to correct routing which was;
Controller_Item and method action_category(8)
The problem is when using modified route;http://mydomain.com/store/1/item/category/8
Output:
Category ID: 1
it become action_category(1) (it takes the parameter from <store_id>)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按名称获取参数:
Get param by name: