singrana / thememanager
Theme manager for Yii2 (simple theme managment for Yii2)
Installs: 436
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2025-04-22 04:56:04 UTC
README
Theme manager for Yii2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist singrana/thememanager "*"
or add
"singrana/thememanager": "*"
to the require section of your composer.json
file.
Usage
Change your application config
'view'=>
[
'theme' =>
[
'class' => 'singrana\thememanager\components\ThemeManager',
'current' => 'site',
'themes' =>
[
'site' =>
[
'pathMap' =>
[
'@app/views' => '@app/themes/site/views',
'@app/views/layouts' => '@app/themes/site/layouts',
],
'defaultLayout' => '//inner',
],
...
],
...
],
],
If you need to change theme, use:
\Yii::$app->view->theme->changeTheme('themeName');
For dynamic create new theme:
\Yii::$app->view->theme->createTheme('newTheme',
[
'pathMap' =>
[
'@app/views' => '@app/themes/admin/views',
'@app/views/layouts' => '@app/themes/admin/layouts',
],
]);
and use new theme:
\Yii::$app->view->theme->changeTheme('newTheme');