【发布时间】:2020-02-21 22:44:14
【问题描述】:
我正在尝试将布局设置为 blank.ctp 但它不起作用,我在 src/Template/Layout 中创建了一个 blank.ctp 但以下代码不起作用,因为在 blank.ctp 文件中没有显示时,默认布局是。
public function delete($id = null)
{
$this->request->allowMethod(['get']);
$this->loadModel('AdminLTETasks');
$adminLTETask = $this->AdminLTETasks->get($id);
if ($this->AdminLTETasks->delete($adminLTETask)) {
echo 'The admin l t e task has been deleted.';
} else {
echo 'The admin l t e task could not be deleted. Please, try again.';
}
$this->viewBuilder()->setLayout('blank');
}
我也尝试过不推荐使用的方法 layout('blank') 并且它也不起作用
public function delete($id = null)
{
$this->request->allowMethod(['get']);
$this->loadModel('AdminLTETasks');
$adminLTETask = $this->AdminLTETasks->get($id);
if($adminLTETask->user_id == $this->Auth->user('id')) {
if ($this->AdminLTETasks->delete($adminLTETask)) {
echo 'The admin l t e task has been deleted.';
} else {
echo 'The admin l t e task could not be deleted. Please, try again.';
}
}
$this->viewBuilder()->layout('blank');
}
【问题讨论】:
-
怎么不工作了?有错误吗?是否正在加载空白.ctp 文件?需要更多详细信息。
-
正在显示默认布局
-
布局是否有可能被重置为默认值,例如
beforeRender回调或delete.ctp本身? -
@GregSchmidt 你一针见血,它在应用程序控制器中被覆盖 beforeRender.... WOOOPS =] 谢谢 Greg
标签: cakephp cakephp-3.x cakephp-3.7