reading this page about modules in Yii 2 I’ve found that you can define a specific layout for your module:
This is working fine but I was wondering if it would also be possible to tell the module to use a different theme, for example for an "admin" module.
Of course a module should be self-contained but if you’re able to specify a theme using the module configuration / when setting up the module, that should be fine, shouldn’t it?
Also, if you are not using a theme for your application (if you did not set the theme component in your config file) you can initialise the component from the init method of the module in this way:
public function init()
{
parent::init();
\Yii::$app->view->theme = new \yii\base\Theme([
'pathMap' => ['@app/views' => '@app/themes/admin/views'],
'baseUrl' => '@web/themes/admin',
]);
}