CController.layout 文档疑问????

CController#layout-detail

在看api文档的时候看到这一句 the name of the layout to be applied to this controller’s views. Defaults to null, meaning the application layout is used. If it is false, no layout will be applied. Since version 1.0.3, the module layout will be used if the controller belongs to a module and this layout property is null.

最后一句话是说:从1.0.3开始 如果一个控制器属于一个模块并且这个layout的属性为null 那么模块的layout将会被使用

按照这样的翻译 如果模块的layout属性为null的话 那不就是使用了 application的layout了(Defaults to null, meaning the application layout is used.)?

是不是我翻译错了?还是文档有错误?

你理解是正确的,可以看下yii的Controller中对layout的解析,getLayoutFile里面的代码

流程是从当前所属的module开始,不停的向上一级module获取layout,如果最终没有获取到,会使用app的layout

其实我现在想说的是 文档最后一句写的是 and this layout property is null.

为什么要让模块的layout属性为null呢?在模块里面public $layout=null;这样模块不就还是使用的是app的布局文件了么?

是不是应该写成 and this layout property is not null.

我的英文也不是很好,但估计是你对这里的文档中英文语法的理解有问题

不看文档,看源码的话你就好理解了

controller->layout 第一层次

module->layout 第二层次

app->layout 第三层次

从上往下,优先级一个比一个高,

null表示使用下一个层次的layout,一旦在某个层次发现layout不为null,则使用之

原来如此 是我理解有误!感谢!