我是cakephp的新手,不过我到处寻找答案,特别是食谱 .
我正在尝试从cakebook的教程中制作我的"tutorial blog"的前端和后端 . 我在( /View/Layouts
)中创建了名为 admin.ctp
, author.ctp
, default.ctp
的不同布局,并且在控制器中有一些代码我可以打赌它会起作用,但不行 .
public function beforeFilter() {
parent::beforeFilter();
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin')
{
$this->layout = 'admin';
}
else if(isset ($this->params['prefix']) && $this->params['prefix'] == 'author')
{
$this->layout = 'author';
}
else
{
$this->layout = 'default';
}
}
它总是选择最后一个default.ctp,我不知道为什么
1 回答
(在问题编辑中回答 . 转换为社区维基答案 . 请参阅Question with no answers, but issue solved in the comments (or extended in chat))
OP写道: