这里是我的线路之一...我可以在Kohana 3中使用一个路径定义吗?
Route::set('products', 'our-products(/<product>)')
->defaults(array(
'controller' => 'products',
'action' => FALSE
));
通过访问/our-products
,你可以得到产品指数(它将调用Controller_Products::action_index()
)。
我要为上班路线如下:添加一个可选的产品的时候,应该调用不同的方法,即如果/our-products/product-a
请求而不是调用Controller_Products::action_index()
,它调用像Controller_Products::action_get('product-a')
。
我意识到我可以用两条路线轻松完成这项工作,但我宁愿用一条路线来完成。
我也虽然关于检查action_index()
内的参数,并调用另一种方法,但听起来很丑。
我也试过__call()
但得到这个非同寻常的错误...
Fatal error: Class declarations may not be nested in /home/user/public_html/~new/system/classes/date.php on line 3
是否有可能做我想做什么?什么是最好的方法?
感谢
为什么你想这样做,在一个路线?为了将不同的请求分离到不同的行为而发明了路由。 – zerkms 2010-12-13 06:59:24
@zerkms他们似乎相关足以进入一条路线。 – alex 2010-12-13 07:08:15
@alex:不同意。如果根据url值有不同的'默认值' - 它们似乎与一个不相关(这是我个人的观点)。 – zerkms 2010-12-13 07:31:20