Lithium中的可选参数?

时间:2012-08-14 15:33:19

标签: php routing lithium

我希望:offset可选。

Router::connect('/some_page/{:offset}/', ...

所以:

Router::connect('/some_page/', ...
Router::connect('/some_page/{:offset}/', ...

两者都走同一条路线。有可能吗?

1 个答案:

答案 0 :(得分:1)

首先更改订单:

Router::connect('/some_page/{:offset}/', ...
Router::connect('/some_page/', ...

然后在控制器中检查是否设置了offset

isset($this->request->params['offset'])