Solve the problem of php crash after paging of yii CGridView when there are too many advanced search options. The reverse import php crashes because there are too many options. In fact, empty options do not need to be added to the paging url. You can put the following code at the bottom of the viewslayoutsmain. php file. The php crash caused by the correction of CGridVie is caused by too many options. In fact, empty options do not need to be added to the paging url.
You can put the following code at the bottom of the views/layouts/main. php file to correct the CGridView paging link address.
[Html]
Yii: app ()-> clientScript-> registerScript ('pagerhref ',"
$ (Function (){
$ ('. Pager a'). each (function (){
Var href = $ (this). attr ('href ');
Var page = href. match (// ([\ w] +) _ page \/([0-9] + )/);
If (page! = Null ){
Page = page [1] + '_ page =' + page [2];
} Else {
Page = '';
}
Var sort = href. match (// ([\ w] +) _ sort \/([\ w] + )/);
If (sort! = Null ){
Sort = sort [1] + '_ sort =' + sort [2];
} Else {
Sort = '';
}
Var fields = $ ('. search-form form'). serializeArray ();
Var data = '';
$. Each (fields, function (I, field ){
If (field. value! = ''){
If (data = ''){
Data + = field. name + '=' + field. value;
} Else {
Data + = '&' + field. name + '=' + field. value;
}
}
});
If (data! = ''& Page! = ''){
Page = '&' + page;
}
If (data! = ''| Page! = '') & Sort! = ''){
Sort = '&' + sort;
}
Var url = '". $ this-> createUrl ($ this-> id.'/'. $ this-> action-> id )."? '+ EncodeURI (data) + page + sort;
$ (This). attr ('href ', url );
});
});
");
?>
Bytes. You can put the following code at the bottom of the views/layouts/main. php file to correct CGridVie...