codeigniter与路线分页

时间:2013-04-14 09:14:21

标签: php codeigniter routing pagination

你好,我有分页代码

//$this->output->enable_profiler(TRUE);
 $this->load->library('pagination');
 $this->load->model('dbs');
$config['base_url'] = site_url('cp/my_walls/');
$config['per_page'] = 5; 
$config['num_links'] = 3;
$config['uri_segment'] = 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ;
$config['total_rows'] = $this->dbs->get_walls_count_by_user();
$this->pagination->initialize($config); 
$curr = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data['title'] = 'User control Panel';
        $data['walls'] = $this->dbs->get_walls_by_user($config["per_page"],$curr); // get limited posts

我也有这个网址的路线

$route['cp/my_walls'] = "main/my_uploaded_wallpapers";
$route['cp/my_walls/(:any)'] = "main/my_uploaded_wallpapers/$1";

这是由deafault工作,它在5个帖子中受到限制。

但是我在分页链接中单击第2页它不再工作

url: site.com/cp/my_walls     - working
url: site.com/cp/my_walls/10     - not working

2 个答案:

答案 0 :(得分:-1)

使用$this->uri->rsegment(n)代替$this->uri->segment(n)

答案 1 :(得分:-1)

试试这个

 $route['news/(:num)'] = "news/index";