Yii2: Rendering view from within the widget

Andrii Kovalenko

What have I tried?

  1. I have created CustomWidget by extending Widget class

  2. In the end of run method body I tried to place by different ways calling render method.

  3. I have tried this ways

$this->render( '//widgets/custom' )

$this->render( 'custom' )

$this->render( '@frontend/views/widgets/custom' )

$this->renderFile(/*absolute path to file*/)

But all in vain.

And with another view, for example

$this->render('//site/404') - Works

I thought maybe the problem the widget is searching for different directory than all other views. I have overridden Widget method getViewPath and intentionally return path to my views. By default getViewPath returns .../components/views. But the error is still exists. I have tried to place widget directory to components/views, but there is no result.

Piece of CustomWidget code

class CustomWidget extends Widget {
    public function run() {
        return $this->render( '/widgets/custom' );
    }
}

I'll be grateful for any clue, suggestion, advice about fixing this problem!

Andrii Kovalenko

The problem is ftp and php users have different groups.

I created file via ftp and the file has different group than php user started with.

Changing group for the widgets/custom.php and group for directory widgets to appropriate to php and set permission to 0770 fixed that issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive