在基本模板上设置新的Yii2主题的问题

时间:2015-11-25 18:06:10

标签: themes yii2

我已根据Themefactory网站和其他SO帖子下载并设置主题,但主题只是加载为纯HTML。这意味着没有格式,只有文本和链接。

这是我在config目录中的web.php文件中的代码:

<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'view' => [
           'class' => 'yii\web\View',
           'theme' => [
               'class' => 'yii\base\dorian',
               'pathMap' => ['@app/views' => 'themes/dorian'],
               'baseUrl'   => 'themes/dorian'
            ],
        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'KecrcGLWURmyPrWp3QBgYuOQ21JuCFA1',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,

文件树的屏幕截图:http://prntscr.com/9708gi

有人看错了吗?

3 个答案:

答案 0 :(得分:0)

 'components' => [
    'view' => [
        'theme' => [
            'basePath' => '@app/themes/tf-dorian',

            'pathMap' => [
                '@app/views' => '@app/themes/tf-dorian',
            ],
            'baseUrl' => '@web/',
        ],
    ],

答案 1 :(得分:0)

请尝试这个,如果它不起作用,请告诉我:

'view' => [
    'class' => 'yii\web\View',
    'theme' => [
      'class' => 'yii\base\Theme',
      'pathMap' => ['@app/views' => 'themes/tf-dorian'],
      'baseUrl'   => 'themes/tf-dorian'
    ]
]

答案 2 :(得分:0)

感谢。我想到了。主题目录必须位于“web”目录下。