【发布时间】:2010-08-25 07:55:31
【问题描述】:
我一直在思考如何在 Kohana 中制作这样的东西:
domain.com/变量
“变量”是用户的标识符。
那么,这可能吗?
http://domain.com/username/controller/action
如果是,请您指出正确的方向吗?
谢谢。
【问题讨论】:
标签: kohana
我一直在思考如何在 Kohana 中制作这样的东西:
domain.com/变量
“变量”是用户的标识符。
那么,这可能吗?
http://domain.com/username/controller/action
如果是,请您指出正确的方向吗?
谢谢。
【问题讨论】:
标签: kohana
如果您有一个名为“联系人”的页面并且用户使用“联系人”作为用户名进行注册,会发生什么情况。将显示哪个页面?
这是我为你整理的一个例子。
// Pages that aren't users.
Route::set('static', '<action>', array('action' => 'sitemap|faq|terms|privacy|credits'))
->defaults(array(
'controller' => 'static'
));
// User routing
Route::set('user', '<username>(/<controller>(/<action>))')
->defaults(array(
'controller' => 'user',
'action' => 'index'
));
所以当这个 URL 被调用时
http://example.com/sitemap
使用第一条路线以及何时使用
http://example.com/arnold
被称为您的用户类和索引方法将被调用。您可以通过以下方式访问用户名变量:
$this->request->param('username');
如果您还有其他问题,请随时提问。
【讨论】: