【问题标题】:codeigniter pagination with routes带有路由的codeigniter分页
【发布时间】:2013-04-06 12:31:09
【问题描述】:

你好,我有分页码

//$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";

这是默认工作,它的帖子限制为 5 个。

但我在分页链接中单击第 2 页,它不再起作用

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

【问题讨论】:

  • var_dump($config['total_rows']) 输出什么?
  • @cryptic ツ int(1241) get_walls_count_by_user();此功能有效
  • 当您的意思是 site.com/cp/my_walls/10 不起作用时,究竟发生了什么?另外,您是否有任何其他路线或 .htaccess 规则可以更新您的问题,以便我们查看某处是否存在冲突?
  • 尝试切换路线中的线路,看看是否有什么不同。

标签: php codeigniter routing pagination


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    试试这个

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

    【讨论】:

      猜你喜欢
      • 2016-01-03
      • 1970-01-01
      • 2013-04-04
      • 2012-11-26
      • 2013-03-16
      • 1970-01-01
      • 2012-01-02
      • 2013-01-16
      • 1970-01-01
      相关资源
      最近更新 更多