|
根据session 过滤的功能和分页功能一起应用时,出现session丢失的现象。见到论坛里很多人问到这个问题,但没有找到解决方案。
后来发现在分页调用时,原有的过滤参数的session值被冲掉了。最终只能来判断是否有分页号决定是否更新session。但第一页的页码值不会出现在URI中。所以这样的解决方式治标不治本。希望高手指点!
PHP复制代码 //将过滤参数存储进session
$newdata['dayview_filter'] = array(
'filter.carNum' => $this->input->post('filter_car'),
'filter.driverId' => $this->input->post('filter_driver_id')
);
if ($this->uri->segment(4) ==''){ //若不加该句时,导致点击分页后,session会更新,原有过滤条件的session被冲掉
$this->_set_last_dis_session ($newdata);
}
$this->load->model('dispatch_mdl');
.......
$this->load->library('pagination');
$config['base_url'] = site_url ('trans/dispatch/todayView');
$config['total_rows'] = $data['total_rows'];
$config['per_page'] = 12;
$config['uri_segment'] = 4;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['first_link'] = '《首页';
$config['last_link'] = '尾页》';
$config['next_link'] = '下页〉';
$config['prev_link'] = '〈上页';
$config['num_links'] = 4;
$this->pagination->initialize($config);
$tmp_off=$this->uri->segment(4);
if(!$tmp_off || !is_numeric($tmp_off)){$tmp_off=0;}
$data['list']=$this->dispatch_mdl->cx_list($this->_corpName ,$tmp_off,$config['per_page'])->result();
$this->_template ('trans/dispatch_today_list_view',$data);
复制代码
|
|