drech
(Agitated)
1
Hey all,
I read in the docs that the default viewPath for view files is protected/views if you call the render with a forward-slashed view name, like so:
$this->renderPartial('/events');
However, the action can’t find the view file if I have it under protected/views/events.php.
So then I figured it probably needed to look under a controller subdirectory to find the view, like this: protected/views/<controller>/events.php.
I’d rather not copy the same view to all these directories, but instead have it globally accessible in one place to all controllers.
Where do I put the view file and how do I specify it’s location in the call to render?
Thanks for any help )
qwerty
(qwerty)
2
Try to create folder in views.
andy_s
(Arekandrei)
3
Strange, it works for me, if I put sample.php file to my viewPath directory and then do renderPartial(’/sample’).
Also try this:
$this->renderPartial('application.views.events');
And make sure viewPath is protected/views (maybe you have changed it?):
echo Yii::app()->viewPath;
drech
(Agitated)
4
Thanks andy_s, this worked:
$this->renderPartial('application.views.events');