2013-12-19 129 views
1

我想使用CodeIgniter分頁,但它不起作用,鏈接顯示,因爲它的意思,我不明白什麼是錯的。使用CodeIgniter分頁將不起作用

按鈕顯示正常(以及「最後」和「第一個」按鈕只顯示在這些頁面中,很高興在每個頁面中看到它們),但生成的頁面很亂。

我在我的表中的下列數據:

text1 
text2 
text3 
text4 

當我設置per_page一個這是當我瀏覽到每一頁會發生什麼:

page 1: text1 
page 2: text3 
page 3: text4 
page 4: text4 

如果我設置use_page_numbers到真正發生這種情況:

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

你可以試試這個:

這裏是展示瞭如何在你的控制器功能之一創建分頁一個簡單的例子:

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