$ this-> layout ='bootstrap'
上面的代码写在我的index
函数上,即使没有登录也可以访问。
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index');
}
public function index() {
$this->layout = 'bootstrap';
}
我测试过,上面的代码不起作用。 (多次)
public function beforeFilter() {
parent::beforeFilter();
$this->layout = 'bootstrap';
$this->Auth->allow('index');
}
public function index() {
}
上面的代码也不起作用。登录时,引导布局会正常呈现,但是当我注销并再次访问它时,视图将呈现为基本HTML。
我有什么问题吗?
解:
我明白了,登录的身份验证是保持引导路径的呈现方式。
由于我在没有登录的情况下访问视图,因此我只需将该特定路径移到authentication子句之外。