我正在尝试使用CodeIgniter分页,但它不起作用,链接显示它喜欢,我不明白什么是错误。
按钮显示正确(“最后”和“第一”按钮仅在这些页面中显示,在每个页面中都可以看到它们很好)但生成的页面很乱。
我的表中有以下数据:
text1
text2
text3
text4
当我将per_page
设置为1时,当我导航到每个页面时会发生这种情况:
page 1: text1
page 2: text3
page 3: text4
page 4: text4
如果我将use_page_numbers
设置为true,则会发生这种情况:
page 1: text1
page 2: text4
page 3: text4
page 4: invalid page (well, redirected because no data from de DB was selected)
我希望能找到一些帮助。我真的不明白发生了什么,手册也没多说。
$config['base_url'] = site_url('foro/lista/'.$pais.'/'.$ciudad);
$config['total_rows'] = $this->foro_model->numero_de_posts($this->util->ciudad_id($ciudad));
$config['per_page'] = 1;
$config['uri_segment'] = 5;
$config['display_pages'] = TRUE;
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$config['full_tag_open'] = '<div class="paginacion-container">';
$config['full_tag_close'] = '</div>';
$config['first_link'] = '<span class="paginacion icon icon-step-backward"></span>';
$config['first_tag_open'] = '';
$config['first_tag_close'] = '';
$config['last_link'] = '<span class="paginacion icon icon-step-forward"></span>';
$config['last_tag_open'] = '';
$config['last_tag_close'] = '';
$config['next_link'] = '<span class="paginacion icon icon-chevron-right">';
$config['next_tag_open'] = '';
$config['next_tag_close'] = '';
$config['prev_link'] = '<span class="paginacion icon icon-chevron-left"></span>';
$config['prev_tag_open'] = '';
$config['prev_tag_close'] = '';
$config['cur_tag_open'] = '<span class="paginacion-cur"><b>';
$config['cur_tag_close'] = '</b></span>';
$config['num_tag_open'] = '<span class="paginacion-num"><b>';
$config['num_tag_close'] = '</b></span>';
$config['anchor_class'] = 'pag-row ';
$this->pagination->initialize($config);
答案 0 :(得分:0)
你可以试试这个:
这是一个简单的示例,展示了如何在一个控制器函数中创建分页:
$this->load->library('pagination');
$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = 200;
$config['per_page'] = 20;
$this->pagination->initialize($config);
echo $this->pagination->create_links();