0
嗨,那么你怎么做到kohana 3.3和kostache?匹配url到标题页
表
<form method="POST" action="user/login">
<input type="text" name="email" />
<input type="passowrd" name="password" />
</form>
控制器
public function action_login()
{
$user = Auth::instance()->login($this->request->post('email'),$this->request->post('password'));
if($user)
{
$view = Kostache_Layout::factory()
$layout = new View_Pages_User_Info();
$this->response->body($this->view->render($layout));
}
else
{
$this->show_error_page();
}
}
类视图
class View_Pages_User_Info
{
public $title= "Profile";
}
胡子模板
<p> This is the Profile Page</p>
到目前为止好,我现在在个人资料页,但网址是
localhost/kohana_app/user/login
,而不是
localhost/kohana_app/user/profile
我知道我可以改变action_login
到action_profile
以匹配网址和页面标题,但有没有其他方法可以做到这一点?
因此,为此,我需要在引导文件中设置另一条路径?是的,然后在我的个人资料页面上使用它。 – Defyleiti
http://kohanaframework.org/3.3/guide/kohana/tips#dont-try-and-use-one-route-for-everything您可以做的最好的事情是删除'默认'示例路线并创建更具体的路线。赶上所有路线都不好。所以如果可以的话,尽量避免它们,它看起来像你从头开始,所以你没有任何借口:p再次:删除'默认'路线。 – Darsstar
好的,非常感谢这个想法。我真的很感谢你的帮助:) – Defyleiti