|
发表于 2013-7-15 17:22:25
|
显示全部楼层
我也碰到和楼主一样的问题,搞了好几天没找到好办法。目前是这样的解决方案:
1. 前台如果想URL美观,貌似只能用js自己拼接URL, 然后再submit
2. 后台我是这样解决的。
比如有个连接 http://test.com/admin/category/index.
三个搜索条件:status, parent_id, name
搜索表单用GET提交,然后在controll里获取这3个条件+翻页per_page.
最后生成的翻页连接是: http://test.com/admin/category/index?status=1&parent_id=-1&name=&per_page=2
PHP复制代码
$page = $this->input->get('per_page'); $page = is_numeric($page) && $page>1 ? $page : 1;
$limit = 20;
$offset = ($page-1)*$limit;
$status = isset($_GET['status']) ? $this->input->get('status') : -1;
$parent_id = isset($_GET['parent_id']) ? $this->input->get('parent_id') : -1;
$name = $this->input->get('name') ? $this->input->get('name') : NULL;
$count = $this->Category->get_categorys($parent_id, $name, $status)->num_rows();
$categorys = $this->Category->get_categorys($parent_id, $name, $status, $limit, $offset)->result();
$this->load->library('pagination');
$config = config_item ('pagination');
$config['base_url'] = base_url ('admin/category/index')."?status=$status&parent_id=$parent_id&name=".urlencode($name);
$config['total_rows'] = $count;
$config['per_page'] = $limit;
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
$pagination = $this->pagination->create_links();
复制代码
|
|