Mohd Shahid
Mohd Shahid

Reputation: 1606

Yii - renderpartial from module to root folder

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..

Upvotes: 4

Views: 7833

Answers (3)

Ricky Riccs
Ricky Riccs

Reputation: 31

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

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

Upvotes: 0

edoceo
edoceo

Reputation: 360

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.

Upvotes: 2

bool.dev
bool.dev

Reputation: 17478

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.

Upvotes: 10

Related Questions