davidjeddy/yii2-pieces-theme

Pieces 主题

2.2 2022-01-04 03:41 UTC

README

关于

pieces-compendium.com 的 Yii2 自定义主题

徽章

--需要 SensioLabs 测试设置-- 最新稳定版本 总下载量 最新不稳定版本 许可 每月下载量 每日下载量

致谢

基于 https://github.com/sheillendra/yii2-theme

安装

  • 在项目根目录下的终端中运行 php composer.phar require davidjeddy/yii2-pieces-theme
  • 或在项目的 composer.json 中 "required": [...] 部分添加 "davidjeddy/yii2-pieces-theme": "^2",然后执行 php composer.phar update -o 命令。

接下来编辑 /application/root/path.env(如果不存在则创建)。编辑 STORAGE_HOST_INFO 的适当值。例如:STORAGE_HOST_INFO = https://storage.pieces-compendium.

然后编辑应用的 ./config/web.php(或类似的文件)

    'components' => [
    ...
        'assetManager' => ['linkAssets' => true],
        'view' => [
            'theme' => [
                'pathMap' => [
                    '@app/views' => '@vendor/davidjeddy/yii2-pieces-theme/src/views',
                ],
            ],
        ],
    ...
],

结构

backend/
    ...
    views/
    web/
        ...
        themes/
            themes_1/
                assets/
                views/
                    layout/
                    controller_name/
                    ...
            themes_2/
            themes_3/

用法

在你的应用程序视图布局文件中初始化主题。

public function init()
{
    parent::init();
    \Yii::$app->view->theme->pathMap[your_module_name.'/views'] = [your_module_name.'/themes/'.\Yii::$app->view->theme->active.'/views'];
    // custom initialization code goes here
}