I am tried to custom url from localhost/?r=site/page&view=about to localhost/?ref=site/page&show=about
or localhost/?ref=site&action=page&show=about ( this will be greater )
I found how to change ‘r’ to ‘ref’ from yiiframework.com/doc/api/1.1/CUrlManager with routeVar
But can’t find to to change ‘view’ to ‘show’ or any other name.
anybody can told me how to working with custom url on Yii?
jodev
(J De Vries)
September 17, 2011, 11:13am
3
The CViewAction uses ‘view’ for the GET parameter by default. If you want to change that, you should extend the action and update the $viewParam property:
<?php
class MyViewAction extends CViewAction
{
public $viewParam = 'show';
}
?>
Next, update your SiteController class:
public function actions()
{
return array(
// ...
'page' => array(
// 'class' => 'CViewAction',
'class' => 'MyViewAction',
),
);
}
Finally, update your views so that any url now uses ‘show’, instead of view:
// Change:
Yii::app()->createUrl('/site/page', array('view' => 'about'))
// To:
Yii::app()->createUrl('/site/page', array('show' => 'about'))
drylko
(Pawel Drylo)
September 18, 2011, 8:38pm
4
Or simply set the viewParam property of CViewAction:
public function actions()
{
return array(
'page' => array(
'class' => 'CViewAction',
'viewParam' => 'show',
),
);
}
Cheers