Override Cviewaction

Hi All

Does anyone knows why the $_viewPath in class CViewAction is private?

I try to extend the CViewAction class but I have no access to $_viewPath variable

My aim is to achieve internal redirection (by $this->forward()) but forward accepts only controller/action without parameters like "view", so I want to pass this parameters by another way


Dear Friend

You can indirectly set the $_viewPath by configuring $basePath.

It is almost like something like this.

$_viewPath=$basePath."/".$GET['view'] //pathOfAlias


The following way ,I can create an another folder for static pages.


public function actions()


		return array(






				'basePath'=>'application.views.land', //indirectly setting viewPath...in protected/views/land folder





[size=2]Dear seenivasan, thank you for response[/size]

Although your code is very useful (for other cases) I want to remove the "view" and "page" from url completely and the only way is to override the getRequestedView method of CViewAction class.

I could modify the core file or clone entire class but I strongly avoid it.

Does anyone has any other suggestion?

Why $_viewPath of CViewAction class is private instead protected?

I remember topics in Yii forum that users refers same issues about private attributes like that.

Will Yii team developers change to protected in next Yii version?


You can achieve that with url manager by adding the following to the very end of rules:

'<view>' => 'site/page',

It seems there is only one way (using urlmanager)

thanks samdark