我的bootstrap.php文件如下所示,所有代码都嵌入在欢迎控制器->action_index中。
Kohana::init(array(
'base_url' => '/kohana/',
'index' => 'index.php'
));好的,如果我把下面的内容放在action_index中
form::open('test');动作是/kohana/index.php/test.
因此,链接似乎是绝对的,您的根安装位置,接受当我嵌入链接在action_index index.php!
html::anchor('controller');href是/kohana/controller not /kohana/index.php/控制器。
现在如果我把
url::site('controller');返回的值是/kohana/index.php/controller.
所以我想我可以用
html::anchor(url::site('controller'));但是href现在等于http://localhost/kohana/kohana/index.php/controller.
世界上发生了什么事,我该怎么解决呢?
Kohana url系统似乎是不直观的,也是错误的。
发布于 2011-04-12 01:05:52
这似乎是HTML::anchor实现中的某种错误。
这是因为html.php的第127行(v3.1.2)
$uri = URL::site($uri, $protocol, $index);在这一行中,$index值根据默认的anchor函数值是FALSE:
public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL, $index = FALSE)因此,您现在所能做的就是-手动传递第5个参数,就像true一样:
html::anchor('controller', null, null, null, true);或者用自定义类扩展Kohana_HTML,如:
class HTML extends Kohana_HTML
{
public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL, $index = TRUE)
{
return parent::anchor($uri, $title, $attributes, $protocol, $index);
}
}或者在kohana bugtracker上填充一个bug,让ko决定该做什么。
https://stackoverflow.com/questions/5629201
复制相似问题