0
votes

How I can access to array of params, passed to controller Action in View? Basicaly before SEO links was applied there was rules in my View (simplified):

foreach(....){
$_GET['filter']=$value;
$link=$this->createUrl('models/showModels',$_GET);
echo CHtml::link(Yii::t('main',$value),$link);
}

But after applying urlManager $_GET variable become to empty, and for sure such rules set stop to work.

I just discover that with some "magic" method it's done in CLinkPager module, but can't understand how.

1
array elements are always accessed by using key. you have done in it your code. by using $_GET['filter'] you are accessing the value of key "filter" in your get array. - Rafay Zia Mir
Have you checked before using $_GET in createUrl that it is not empty? - Rafay Zia Mir
As soon as UrlManager rules appliet the "old" urls like aaa.com/show?brand=BMW become to new SEO friendly: aaa.com/BMW Due this reason $_GET always emty and "parsed" variables are stored somewhere else. Now I trying to findout where it's stored and how I can access it. - Val KH

1 Answers

1
votes

In Yii you can get param with the following method:

Yii::app()->request->getParam('param_name');
// for example getParam('filter')
// OR Yii::app()->request->getQuery('$_GET KEY');

In order to merge params to $_GET request:

CMap::mergeArray($_GET, array('filter' => 'value'))

In order to get all params:

Yii::app()->request->getQueryString();

Also, Yii has a powerful method to get Dump that I suggest you to use it:

CVarDumper::dump($_GET,34567,true);