我们可以在那个特定的 Controller 中为整个 Controller 定义一个布局吗?我之前已经为此目的使用了 appcontroller 之前的过滤器,但它不再解决它了。所以我需要在 Controller 中应该有一些布局定义将适用于该 Controller 的所有操作。
问候
最佳答案
使用它:
在你的行动中
$this->layout = 'mylayout';
你必须在 view/layout/mylayout.ctp 中创建布局
或者在controller中添加这个函数来为controller的每个action设置layout
function beforeFilter() {
parent::beforeFilter();
$this->layout = 'mylayout';
}
关于php - 在 cakephp 中分配布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7426469/