4

i am trying to render the view from module to project base view but it gives error.

I tried below combinations without any luck. It gives the error "DefaultController cannot find the requested view "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"=>""));

and tried with extensions too

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"=>""));

I am in "Forms" module and trying to render a file "protected/views/site/appsMenu.php". Plz help me..

Mohd Shahid
  • 1,538
  • 2
  • 33
  • 66

3 Answers3

10

Use //:

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

This can be seen in the documentation

absolute view within the application: the view name starts with double slashes '//'. In this case, the view will be searched for under the application's view path. This syntax has been available since version 1.1.3.

bool.dev
  • 17,508
  • 5
  • 69
  • 93
2

This nasty little bit did the trick for me

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

Using // to alias to $root/protected/views and then putting that ../ bit in there to get me to $root/protected/views/../modules/$m/views/$c/$v which really means $root/protected/modules/$m/views/$c/$v

Of course, put reasonable values in for the $X and/or MyXXX values above.

edoceo
  • 360
  • 3
  • 7
0
require_once('./protected/modules/MyMod/views/MyCon/MyView.php');

Use above line if you are not able to render file using yii

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Ricky Riccs
  • 41
  • 1
  • 5