jzhong5
(Jzhong5)
1
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'];
perochak
(Amjad Mughal)
2
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
jzhong5
(Jzhong5)
3
Hi, I don’t really understand your code. My GET var are not USERS attributes. How can I get them then?
Thank you!
jzhong5
(Jzhong5)
4
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
perochak
(Amjad Mughal)
5
Can you please share your code
perochak
(Amjad Mughal)
6
Yes, if you can use params property of CPagination to do this, check
http://www.yiiframework.com/doc/api/1.1/CPagination
jzhong5
(Jzhong5)
7
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…
perochak
(Amjad Mughal)
8
in the data provider, you can use CPagination…
$dataProvider->pagination->params= array(
'aid'=>1,
'bid'=>1,
);
(Code not tested)
jzhong5
(Jzhong5)
9
Sorry but this code only add parameters when I change page…It doesn’t add params for the search url…
perochak
(Amjad Mughal)
10
Send me url page full code in pm
jzhong5
(Jzhong5)
11
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;?>">