Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何定制Yii2框架的渲染功能_Php_Yii2 - Fatal编程技术网

Php 如何定制Yii2框架的渲染功能

Php 如何定制Yii2框架的渲染功能,php,yii2,Php,Yii2,我想把yii2的views文件夹改为structure bellow views ----default ----site ----index.php ----error.php ----login.php 在siteController中,我使用下面的代码 public function actionIndex(){ return $this->render('default/index'); } 和错误 The vi

我想把yii2的views文件夹改为structure bellow

 views
----default
    ----site
        ----index.php
        ----error.php
        ----login.php
在siteController中,我使用下面的代码

public function actionIndex(){
    return $this->render('default/index');
}
和错误

The view file does not exist: D:\wamp\www\yii2\backend\views\site\default/index.php

请使用您当前的代码帮助我,站点管理员在其视图文件夹下搜索视图文件,您需要获得正确的路径:

$this->render('../default/site/index');
我建议为您的主本地文件创建一个更灵活的别名,如@default\u视图:

'aliases' => [
        '@default_views' => '../default/',
因此,功能:

public function actionIndex(){
    return $this->render(Yii::getAlias('@default_views') . 'site/index');
}
可能重复或只是
$this->render('/default/site/index')。。。或者更好:为控制器设置
viewPath