Yii Framework Forum: Override Cviewaction - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Override Cviewaction private $_viewPath limits Rate Topic: -----

#1 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,325
  • Joined: 21-February 11
  • Location:Greece

Posted 01 May 2013 - 06:39 AM

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


Thanks
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#2 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 01 May 2013 - 09:32 AM

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.

SiteController.php

public function actions()
	{
		return array(
			'page'=>array(
				'class'=>'CViewAction',
			),
			'land'=>array(
				'class'=>'CViewAction',
				'basePath'=>'application.views.land', //indirectly setting viewPath...in protected/views/land folder
			),
		);
	}


Regards.
0

#3 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,325
  • Joined: 21-February 11
  • Location:Greece

Posted 01 May 2013 - 10:01 AM

Dear seenivasan, thank you for response

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.
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#4 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,325
  • Joined: 21-February 11
  • Location:Greece

Posted 02 May 2013 - 12:37 PM

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?
Thanks
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,602
  • Joined: 17-January 09
  • Location:Russia

Posted 03 September 2013 - 02:42 AM

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

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

Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#6 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,325
  • Joined: 21-February 11
  • Location:Greece

Posted 03 September 2013 - 09:08 AM

View Postsamdark, on 03 September 2013 - 02:42 AM, said:

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
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users