2013-02-11 82 views
1

我嘗試使用$layout財產在我的控制器,但我總是得到以下錯誤:

Call to a member function nest() on a non-object

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'); 
    } 
} 

我可能會錯過一些東西,但我不能找到它docs

回答

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'); 
    } 
}