質問

I have a widget class inside "~/common/extensions/my_widget"

It renders: "~/common/extensions/my_widget/views/index"

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

When i make a new application in "~/myapplication/" how is it possible to override the widget view for only "myapplication" and if there is no view found, use the default view.

~ is my basefolder

役に立ちましたか?

解決

Inside config, add your view:

'components' => [
    ...
    'view'=> [
        'theme' => [
            'pathMap' => [
                '@common/extensions/my_widget/views' => [
                    '@myapplication/views/widgets/my_widget/views', // Override
                    '@common/extensions/my_widget/views', // Default
                ],
            ],
        ],
    ]
],
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top