Question

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

Was it helpful?

Solution

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
                ],
            ],
        ],
    ]
],
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top