0

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

4

2 回答 2

1

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

$config["uri_segment"]  = $this->uri->segment(4);
于 2013-09-12T13:40:24.130 回答
0

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

于 2013-10-28T07:00:25.887 回答