2

我在“~/common/extensions/my_widget”中有一个小部件类

它呈现:“~/common/extensions/my_widget/views/index”

public function run()
{
  echo $this->render( '@common/extensions/my_widget/views/index');
}

当我在“~/myapplication/”中创建一个新应用程序时,如何仅覆盖“myapplication”的小部件视图,如果没有找到视图,请使用默认视图。

~ 是我的基本文件夹

4

1 回答 1

2

在配置中,添加您的视图:

'components' => [
    ...
    'view'=> [
        'theme' => [
            'pathMap' => [
                '@common/extensions/my_widget/views' => [
                    '@myapplication/views/widgets/my_widget/views', // Override
                    '@common/extensions/my_widget/views', // Default
                ],
            ],
        ],
    ]
],
于 2014-04-17T13:34:38.863 回答