CI分页和路由问题
不加路由,分页好好的,加路由就不行了,帮忙看看,,,,,路由代码
$route['default_controller'] = 'article';
$route['article/(:num)']= 'article/article_view/$1';
$route['list/(:num)'] = 'article/article_list/$1';
C代码
function article_list($typeid){
$map['typeid'] = intval($typeid);
$query=$this->db->get_where('article',$map);
$rows = $query->num_rows();
//分页start
$config['base_url'] = base_url().'article/article_list/'.$map['typeid'];//路由后的=>//base_url().'list/'.$map['typeid'];
$config['uri_segment'] = 4; //路由后的=>//$config['uri_segment'] = 3;
$config['total_rows'] = $rows;
$config['per_page'] = 5;
$config['num_links'] = 4;
$config['first_link'] = '首页';
$config['last_link'] = '尾页';
$config['suffix'] = '.shtml';
//$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
$query=$this->db->get_where('article',$map,$config['per_page'],$this->uri->segment(4)); //路由后的=>//3
$list = $query->result_array();
$page = $this->pagination->create_links();
$data = array('list'=>$list,'page'=>$page);
$this->header();
$this->load->view('article/article_list',$data);
$this->footer();
}
怎么没人啊 这里可以解决你的问题
http://codeigniter.org.cn/forums/thread-6729-1-1.html
156行
// Determine the current page number.
$CI =& get_instance();
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
if ($CI->input->get($this->query_string_segment) != $base_page)
{
$this->cur_page = $CI->input->get($this->query_string_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
else
{
//else 语句中 $CI->uri->segment 应该改为 $CI->uri->rsegment,否则如果使用路由重写则分页不能正确指向当前分类
if ($CI->uri->rsegment($this->uri_segment) != $base_page)
{
$this->cur_page = $CI->uri->rsegment($this->uri_segment);
// Prep the current page - no funny business!
$this->cur_page = (int) $this->cur_page;
}
}
页:
[1]