我正在尝试从模块到项目基础视图渲染视图,但它会出错。
我尝试了以下组合而没有任何运气。它给出错误“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”。 Plz帮助我..
答案 0 :(得分:10)
使用//
:
$this->renderPartial("//site/appsMenu");
这可以在documentation
中看到应用程序中的绝对视图:视图名称以双斜杠“//”开头。在这种情况下,将在应用程序的视图路径下搜索视图。此语法自1.1.3版开始提供。
答案 1 :(得分:1)
对我来说,这个令人讨厌的一点点诀窍
$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值设置合理的值。