在使用了module,theme技术后,layout怎么放置科学?

我认为的科学位置是:

顶级layout(例如:main.php)放在themes/classic/views/layouts/ 目录下

二级layout(例如:layout1.php layout2.php )放在themes/classic/views/{module1}/layouts/ 目录下

我按照上面的方式存放后,发现会找不到二级layout,请问我怎样debug action选择的layout范围?或者是我错在哪里了?

位置的确是这样没错。你设置了module的 layout属性没有?如果没有,那么用的是application的layout。

module的layout属性在哪里配置呢?

在module class的init()里。

我在每个action里面都设置了 $this->layout='layout2';了 在module里面怎么设置呢?按道理应该就不用设置了啊?

init(){

$this->setViewPath("themes/classic/views/{module1}/layouts");

}

这样设置?

如果theme变了。路径也得变的。

不是设置路径,而是设置layout名字。

$this->layout='something';

我在每个action里面都设置了 $this->layout='layout2';了 有些设置了layout1

module里面在设置的话,没法设置了。是设置layout2还是layout1 ,感觉都不合适。

你在action里设置也可以。这样应该在themes/classic/views/{module1}/layouts下找。

你可以参看CTheme::getLayoutFile()和CController::resolveViewFile()。