I am currently in a certain controller and inside i am trying to load a view from a completly different directory. The code above does not work and throws an exception that the view file was not found:
admin_group_form__core cannot find the requested view "C:\wamp\www\all_mighty_yii\Protected\modules\admin\views\default/core/groups/groups_index".
I do want to allow the option to load the view from a different directory.
Wouldn’t help much. I know the path the view resides in, I want to load it with renderpartial but i think the system looks up the view under the current used controller.
CController use getViewPath() to determine where is view file. Your controller extends from CController and has this default method. Child class can override method comes from parent. And make other methods ( render(), renderPartial(),… ) use Child’s new method.
If you move the function outside your controller, your controller will use old function comes from parent.
If you want to switch view file path between yii default path and your path. Maybe you can use a object variable to select, which is like the following code.
Insert a new variable in your controller class.
public $viewPathSelector;
and change the getViewPath().
public function getViewPath()
{
switch($this->viewPathSelector)
{
case 1:
$result='/your/view/path';
break;
default:
$result=parent::getViewPath();
break;
}
return $result;
}
now you can select what view file path your controller action use.
following code is inside your controller.
public function actionIndex()
{
$this->viewPathSelector=0; //will use yii default path
$this->render('index');
$this->viewPathSelector=1; //will use '/your/view/path'
$this->renderPartial('your_view');
}