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.
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.
and change the getViewPath().
public function getViewPath()
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->viewPathSelector=1; //will use '/your/view/path'