Yii Search Destroy All The Old Get Value In The Address Bar. Help Please

Dear all,

I have a webpage with the following address:


www.123.com/test?aid=1&bid=2

When I implement search in my page, my url will be changed to


www.123.com/test?Users%5Busername%5D=admin&yt0=Search

You can see that all my old GET value disappears.

How can I get my old GET value back so I still get


www.123.com/test?aid=1&bid=2&Users%5Busername%5D=admin&yt0=Search


Attached are some codes for the search


   $user=new Users('search');

   $user->unsetAttributes(); 

   if(isset($_GET['Users']))

   $user->attributes=$_GET['Users'];

As model is User and the attributes will be based on model so you should have them as




// URL

index.php?r=search/index&Users[aid]=1&Users[bid]=2



By this

your search code




if(isset($_GET))

$user->attributes=$_GET['Users'];



will assign the values to user model properties i.e. aid and bid

thanks

Hi, I don’t really understand your code. My GET var are not USERS attributes. How can I get them then?

Thank you!

Hi, this didn’t really solve my problem. aid and bid are not variables from USERS. They are simply some GET variables I need.

Are there any way to append some thing like


&aid=10&bid=20

after the whole search link?


index.php?r=search/index&Users[user]=admin

Can you please share your code

Yes, if you can use params property of CPagination to do this, check

http://www.yiiframework.com/doc/api/1.1/CPagination

Hi, I check the link…Should I use pageVar or something like that…?

Here are my codes for the Dataprovider:


$dataProvider->pagination->pageSize = 30;

$dataProvider->sort->defaultOrder='active DESC';

$dataProvider->criteria->offset='0';

$dataProvider->criteria->limit='300';

$this->widget('zii.widgets.CListView', array(

             'id'=>'userslist',

             'dataProvider'=>$dataProvider,

             'itemView'=>'_teammore',

             'template'=>'{items}<div class="clear"></div><div style="margin-right:10px;">{pager}</div>',

             'pagerCssClass'=>'right',

'afterAjaxUpdate'=>false,

'sortableAttributes'=>array(

      //  'create_time'=>'Time',

    ), 

));

I just need to append aid & bid GET values in this page…

in the data provider, you can use CPagination…




$dataProvider->pagination->params= array(

'aid'=>1,

'bid'=>1,


);



(Code not tested)

Sorry but this code only add parameters when I change page…It doesn’t add params for the search url…

Send me url page full code in pm

Thank you but I just finished this by a dirty way

add something like


<input style="display:none; margin-left:20px;" name="aid" id="search_aid" type="text" maxlength="30" value="<?php echo $aid;?>">


<input style="display:none; margin-left:20px;" name="bid" id="search_bid" type="text" maxlength="30" value="<?php echo $bid;?>">