Вопрос

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