I have the following route set at the end of the route list for my site which allows a final check on the uri value to provide my site users with a vanity URL (http://example.com/username
)
我在我的网站的路由列表末尾设置了以下路由,允许最终检查uri值,以便为我的网站用户提供虚URL(http://example.com/username)
Route::set('profile', '<path>/(<page>)',
array(
"path" => "[a-zA-Z0-9_-]+",
"page" => (blog|photos)))
->defaults(array(
'controller' => 'welcome',
'action' => 'profile'
));
This route directs properly to the welcome
controller and the profile
method, however I was wondering if there was a way to get the path
and page
values sent to the method like so:
此路由正确指向欢迎控制器和配置文件方法,但我想知道是否有办法将路径和页面值发送到方法,如下所示:
action_profile($var1, $var2) {
echo $var1 . ' ' . $var2;
}
I don't want to rely on $this->request->uri()
and exploding the result into an array unless there is absolutely no other way of doing this.
我不想依赖$ this-> request-> uri()并将结果爆炸成数组,除非绝对没有其他方法可以做到这一点。
1 个解决方案
#1
1
Read the manuals please: http://kohanaframework.org/3.0/guide/kohana/routing#request-parameters. $this->request->param('param-name')
will helps.
请阅读手册:http://kohanaframework.org/3.0/guide/kohana/routing#request-parameters。 $ this-> request-> param('param-name')会有所帮助。
#1
1
Read the manuals please: http://kohanaframework.org/3.0/guide/kohana/routing#request-parameters. $this->request->param('param-name')
will helps.
请阅读手册:http://kohanaframework.org/3.0/guide/kohana/routing#request-parameters。 $ this-> request-> param('param-name')会有所帮助。