简体   繁体   English

Fuelphp-在重写路径中将默认参数传递给控制器

[英]Fuelphp - pass default parameter to a controller in a rewrote route

I want to do something I thought was pretty basic using fuelphp Basically I need to use multiple urls with only one controller, and assign each different route a default parameter (a cat id for that matter) 我想做一些我认为使用fuelphp非常基本的事情基本上,我只需要使用一个控制器使用多个URL,并为每个不同的路由分配一个默认参数(就此而言为cat id)

For instance in my Listing controller I want to use 2 different routes : 例如在我的清单控制器中,我想使用2条不同的路线:

/bags
/accessories

to each of which would be assigned it's cat id 分配给每一个猫的ID

Can't seem to find any easy way to do it in fuelphp... 似乎无法在fuelphp中找到任何简单的方法来做...

You can specify a route like 'path/here/(:segment) => 'controller/cat/$1 which will then pass the segment captured in the route as the first parameter to a method called action_cat in the controller class. 您可以指定一条路径,例如'path/here/(:segment) => 'controller/cat/$1 ,然后将路径中捕获的段作为第一个参数传递给控制器​​类中名为action_cat的方法。

This behaviour is pretty well outlined in the documentation http://fuelphp.com/docs/general/routing.html http://fuelphp.com/docs/general/routing.html文档中对此行为进行了很好的概述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM