【问题标题】:Some bug with code igniter pagination library代码点火器分页库的一些错误
【发布时间】:2013-09-12 13:03:17
【问题描述】:

在我的应用程序中,我允许用户写博客。现在有一个通用主页,显示所有用户的所有博客,它的分页代码是

$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);

这是完美的工作,但我不知道用户分页功能有什么问题,我只选择了来自该用户的博客

$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);

现在分页在欢迎屏幕上工作得很好,但在用户屏幕上却不行

【问题讨论】:

    标签: php codeigniter pagination codeigniter-2


    【解决方案1】:

    您还需要提供以下信息来告诉分页类当前偏移量是多少:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2011-12-18
        • 2016-03-15
        • 2011-09-27
        • 2016-01-13
        • 2018-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多