Layout Yii模块,主题布局包括模块布局。怎样才能做到这一点?

Layout Yii模块,主题布局包括模块布局。怎样才能做到这一点?,layout,module,yii,themes,Layout,Module,Yii,Themes,我需要这样做: 我在/themes/panel中有主题“panel”,其中有layout/themes/panel/views/layouts/main.php和示例内容 <a>$content</a> <b>$content</b> $content 我在/protected/modules/admin中有模块“admin”,还有layout/protected/modules/admin/view/layouts/main.php和示例内

我需要这样做:

我在/themes/panel中有主题“panel”,其中有layout/themes/panel/views/layouts/main.php和示例内容

<a>$content</a>
<b>$content</b>
$content
我在/protected/modules/admin中有模块“admin”,还有layout/protected/modules/admin/view/layouts/main.php和示例内容

<a>$content</a>
<b>$content</b>
$content
最后我想要

<a><b>view</b></a>
视图
同样在/themes/panel/views/layouts/main.php中,我需要从模块中加载css文件


在其他解释中: 我有一个用于所有面板(页眉、css文件、页脚)的模板,但每个面板都需要单独的布局(只有菜单等内容更改的中间部分)和一个或多个单独的css文件


此外,一些图像将包含在主主题中,其他图像将单独用于模块。

您可以使用renderPartial功能加载布局的各个部分

<?= $this->renderPartial('webroot.themes.' . Yii::app()->theme->name . '.views.layouts.' . Yii::app()->layout . '.<PART_OF_LAYOUT>') ?>

我不同意在互联网的许多帮助论坛中,当有人要求对模块进行主题化时,每个人都会建议主题文件夹的路径别名。我认为这是错误的,因为它意味着要拆分模块,模块应该是一个可以跨项目使用的黑盒。只有在多个模块共享一个主题的情况下,此类论坛中给出的建议才有效。如果有人想在模块中“打包”主题,她可以: -向模块的控制器添加一个init函数 -在该init内部,使用类属性布局和路径别名,如下所示,使用id为“Sample”的模块: 然后将以下内容添加到SampleCOntroller.php:

public function init() {
    //BELOW: it will use the layouts/main.php inside the module.
    $this->layouts = "sample.views.layouts.main"; 
}
您可以在此处查看路径别名:

Thx,我会检查这个。对于X模块中的所有视图,我应该以何种方式加载/protected/modules/X/views/layouts/main.php?我需要以应用程序知道的方式加载模块文件夹中的图像,但我也需要从/themes/panel/img加载图像。