Reputation: 117
I want to change views folder of yii2 to structure bellow
views
----default
----site
----index.php
----error.php
----login.php
In the siteController i'm using code bellow
public function actionIndex(){
return $this->render('default/index');
}
and error
The view file does not exist: D:\wamp\www\yii2\backend\views\site\default/index.php
Please help me
Upvotes: 1
Views: 610
Reputation:
With your current code, the Site Controller search the view file under his view's folder /views/site
, you need to get the right path:
$this->render('../default/site/index');
I suggest to create an alias for be more flexible, like @default_views in your main-local file:
'aliases' => [
'@default_views' => '../default/',
So, the function:
public function actionIndex(){
return $this->render(Yii::getAlias('@default_views') . 'site/index');
}
Upvotes: 1