【问题标题】:How to override view via themes? (yii2)如何通过主题覆盖视图? (yii2)
【发布时间】:2021-04-03 20:24:25
【问题描述】:

我需要覆盖像 'pathMap' => ['@dektrium/user/views' => '@app/views/site'] 这样的视图文件无论我做什么都是旧观点。 baseUrl 或 basePath 可能有问题,但我不确定我应该怎么做。

前端/config/main.php:

'components' => [
'request' => [
            'csrfParam' => '_csrf-frontend',
            'baseUrl' => '/',
        ],
// .................
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '/' => 'site/index',
                '<action:\w+>' => 'site/<action>',
            ],
        ],
'view' => [
       'class' => 'yii\web\View',
            'theme' => [
                //'basePath' => '@app/themes/basic',
                //'baseUrl' => '@app/views/site',
                'pathMap' => [
                    '@dektrium/user/views' => '@app/views/site'
                ]
            ]
        ]
//.................
]

common/config/main.php:

'modules' => [
'user' => [
            'class' => 'dektrium\user\Module',
            'admins' => ['admin'],
            'modelMap' => [
                'User' => 'common\models\User',
            ],
]

我在 mydomain.test/user/register 之类的地址上打开页面(以防万一) 我还尝试将“视图”部分放在 common/config/main.php 和模块的组件中。尝试创建主题文件夹并将新视图放入其中,似乎没有任何效果

【问题讨论】:

    标签: php view yii yii2


    【解决方案1】:

    好的,我终于修好了

    'view' => [
                'class' => 'yii\web\View',
                'theme' => [
                    'basePath' => '@frontend/views/site',
                    'baseUrl' => '@frontend/views/site',
                    'pathMap' => [
                        '@dektrium/user/views/registration' => '@frontend/views/site',
                    ]
                ]
            ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      • 2019-10-15
      相关资源
      最近更新 更多