2

所以我试图通过 Kohana 的第 3 版指南,并在 hello world create view 部分不断收到错误。

ErrorException [ Warning ]: Attempt to assign property of non-object
Line 8: $this->template->message = 'hello world';

我将 site.php 放在 application/views 文件夹中...这是错误的地方...?

编码....

public $template = 'site';

public function action_index()
{
        $this->template->message = 'hello world';
}

如果有人能阐明我做错了什么,我将不胜感激......谢谢

4

2 回答 2

4

哎呀忘了扩展正确的控制器。

class Controller_Welcome extends Controller {

需要有

class Controller_Welcome extends Controller_Template {
于 2009-11-15T05:52:00.740 回答
2

你可能会发现你需要添加

public function before()
{
   parent::before();

}

在您的 Controller_Welcome 中,以便它将预加载和引用扩展控制器

于 2011-06-29T02:35:59.613 回答