在cakephp中分配布局 [英] Assigning Layout in cakephp
本文介绍了在cakephp中分配布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在这个特定的控制器中为整个控制器定义一个布局吗?我之前使用的过滤器之前的appcontroller为此目的,但它不解决它任何更多。我需要控制器中的布局的一些定义
Can we define a Layout for whole controller in that particular controller?I have used before filter of the appcontroller for this purpose earlier but it doesnt solves it any more.So i need that there should be some definition of layout in controller that would apply for all the actions of that controller.
注意
推荐答案
使用它:
inside your action
$this->layout = 'mylayout';
您必须在view / layout / mylayout.ctp中创建该布局
you have to create that layout in view/layout/mylayout.ctp
或将此函数添加到控制器以为控制器的每个操作设置布局。
or add this function to controller to set layout for each action of controller
function beforeFilter() {
parent::beforeFilter();
$this->layout = 'mylayout';
}
这篇关于在cakephp中分配布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文