简体   繁体   English

代码点火器分页库的一些错误

[英]Some bug with code igniter pagination library

In my application i'm allowing user to write a blog. 在我的应用程序中,我允许用户编写博客。 Now there is a universal homepage which shows all blogs by all user and it's pagination code is 现在有一个通用主页,显示所有用户的所有博客,其分页代码为

$this->load->library('pagination');
$config['base_url'] = "http://localhost/old/lostfoundproject/index.php/welcome/index";
$config['per_page'] = 3;
$config['num_links'] = 10;
$config['total_rows'] = $this->db->get('table_name')->num_rows();
$this->pagination->initialize($config);
$this->load->model('welcome_model');
$data['records'] = $this->welcome_model->get_all_blogs($config['per_page'],$this->uri->segment(3));
    $this->load->view('welcome_message',$data);

which is working perfectly but i don't know what is the problem with the user pagination function where i've made just a little change of select just those blogs which are from that user 这工作正常,但是我不知道用户分页功能有什么问题,我只对来自该用户的那些博客进行了少许选择

$this->load->library('pagination');
$config['base_url'] = "http://localhost/old/lostfoundproject/index.php/user/page/user_home/";
$config['per_page'] = 3;
$config['num_links'] = 10;
$config['total_rows'] = $this->db->get_where('table_name',array('user_id'=>$this->session->userdata('some_id')))->num_rows();
    $this->pagination->initialize($config);
    $this->load->model('user_model');
    $data['records'] = $this->user_model->get_all_blogs($config['per_page'],$this->uri->segment(4));
    $this->load->view('user/user_home',$data);

now the pagination is working perfectly for the welcome screen but not for user screen 现在分页在欢迎屏幕上工作正常,但在用户屏幕上工作不正常

您还需要提供以下内容来告诉分页类当前的偏移量是什么:

$config["uri_segment"]  = $this->uri->segment(4);

Please replace $this->uri->segment(4) to $this->uri->rsegment(3); 请将$ this-> uri-> segment(4)替换为$ this-> uri-> rsegment(3); or you can check this link also http://ellislab.com/codeigniter/user-guide/libraries/uri.html 或者您也可以查看此链接http://ellislab.com/codeigniter/user-guide/libraries/uri.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM