singrana / thememanager
Yii2的主题管理器(为Yii2提供的简单主题管理功能)
dev-master
2016-03-11 09:08 UTC
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-24 02:34:07 UTC
README
Yii2的主题管理器
安装
安装此扩展的首选方法是通过composer。
运行以下命令之一:
php composer.phar require --prefer-dist singrana/thememanager "*"
或者
"singrana/thememanager": "*"
将以下内容添加到您的composer.json文件的require部分。
使用方法
修改您的应用程序配置
'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',
],
...
],
...
],
],
如果您需要更改主题,请使用
\Yii::$app->view->theme->changeTheme('themeName');
动态创建新主题
\Yii::$app->view->theme->createTheme('newTheme',
[
'pathMap' =>
[
'@app/views' => '@app/themes/admin/views',
'@app/views/layouts' => '@app/themes/admin/layouts',
],
]);
并使用新主题
\Yii::$app->view->theme->changeTheme('newTheme');