Yii -将模块中的partial渲染到根文件夹中

j2cgzkjk  于 2022-11-09  发布在  其他
关注(0)|答案(3)|浏览(153)

我尝试将视图从模块渲染到项目基础视图,但它给出了错误。
我尝试了下面的组合,但没有任何运气。它给出了错误“DefaultController找不到请求的视图“appsMenu”。”

echo $this->renderPartial("appsMenu",array("moduleName"=>""),true, true);
echo $this->renderPartial("//appsMenu",array("moduleName"=>""));
echo $this->renderPartial("views/site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("views/site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("protected/views/site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("/protected/views/site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("views/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("/views/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("site/views/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("site/views/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("protected/views/site/appsMenu",array("moduleName"=>""));
echo $this->renderPartial("//protected/views/site/appsMenu",array("moduleName"=>""));

并尝试扩展

echo $this->renderPartial("appsMenu.php",array("moduleName"=>""),true, true);
echo $this->renderPartial("//appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("views/site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("views/site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("protected/views/site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("/protected/views/site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("views/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("/views/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("site/views/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("site/views/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("protected/views/site/appsMenu.php",array("moduleName"=>""));
echo $this->renderPartial("//protected/views/site/appsMenu.php",array("moduleName"=>""));

我在“表单”模块,并试图呈现一个文件“protected/views/site/appsMenu.php”。请帮助我。

7xzttuei

7xzttuei1#

使用//

$this->renderPartial("//site/appsMenu");

这可以在文档中看到
应用程序中的绝对视图:视图名称以双斜杠“//”开头。在这种情况下,将在应用程序的视图路径下搜索视图。此语法从1.1.3版开始可用。

kq4fsx7k

kq4fsx7k2#

这个讨厌的小东西对我起了作用

$this->renderPartial('//../modules/MyMod/views/MyCon/MyView');

使用//作为$root/protected/views的别名,然后将../位放入其中,得到$root/protected/views/../modules/$m/views/$c/$v,实际上是$root/protected/modules/$m/views/$c/$v
当然,为上面的$X和/或MyXXX值输入合理的值。

fzsnzjdm

fzsnzjdm3#

require_once('./protected/modules/MyMod/views/MyCon/MyView.php');

如果您无法使用yii渲染文件,请使用上面的行

相关问题