我尝试在控制器中使用$layout
属性,但我总是遇到以下错误:
在非对象
上调用成员函数nest()
当dd()
this->layout
的值时,它似乎只是一个字符串。
这是我的代码:
base.php
class Base_Controller extends Controller {
public $layout = 'layouts.common';
}
admin.php的
class Admin_Controller extends Base_Controller {
public function action_index() {
$this->layout->nest('content', 'admin.home');
}
}
我可能会错过一些东西,但我在文档中找不到它
答案 0 :(得分:0)
__construct
来添加过滤器,但没有调用父构造:
class Admin_Controller extends Base_Controller {
public function __construct() {
parent::__construct();
$this->filter('before', 'auth');
}
public function action_index() {
$this->layout->nest('content', 'admin.home');
}
}