我正在制作包含项目中所有日志的日志表。使用CI的分页我创建了分页数据。现在问题是我必须根据不同的日志类型和分页过滤日志,我已经尝试了很多,但仍然无法弄清楚如何生成搜索的分页链接。我正在粘贴控制器代码 谢谢。
{
if($this->input->post('show'))
$logtype_filter = $this->input->post('log_type');
else
$logtype_filter ='';
// load pagination class
$this->load->library('pagination');
$config['base_url'] = base_url().'admin/logs/';
$config['total_rows'] = $this->db->count_all('netsynclogtable');
$config['per_page'] = '20';
$config['first_link'] = FALSE;
$config['last_link'] = FALSE;
$config['prev_link'] = 'Previous';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li class="previous">';
$config['prev_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active">';
$config['cur_tag_close'] = '</li>';
$this->pagination->initialize($config);
//load the model and get results
$this->load->model('Logger_model');
$data['logs'] = $this->Logger_model->get_logs($config['per_page'],$this->uri->segment(3),$logtype_filter);
$data['logtypes'] = $this->Logger_model->get_log_types();
$data['_view'] = 'admin/logs';
// load the view
$this->load->view('layouts/admin',$data);
}
答案 0 :(得分:0)
我建议您查看Datatables。它几乎支持您对表所需的所有操作。还有Codeigniter library,但我还没有测试过它
答案 1 :(得分:0)
尝试在base_url中添加您的日志类型,如下所示:
$config['base_url'] =
base_url().'admin/logs?log_type='.$this->input->get('log_type', TRUE)';
我在这里使用了GET请求,因为单击pager中的NEXT链接HTTP方法称为GET而不是POST。因为帖子只会在您提交serach表单时生效。因此,一旦提交了搜索表单并且结果显示为分页,现在点击封装链接GET请求被生成,因为serach表单未提交。
希望这有帮助。