2012-04-26 85 views
0

我花了一些時間,但無法弄清楚什麼是錯的。我使用CodeIgniter 2.1.0。爲什麼CodeIgniter分頁鏈接膨脹?

所以基本上它是這樣的:

我的分頁設置:

$config['base_url'] = base_url() . '/stores/'; 
$config['total_rows'] = $this->stores_model->getTotalRows(); 
$config['per_page'] = 20; //display 20 rows per page 
$config['num_links'] = 10; //display 10 pagination links 
$config['uri_segment'] = 2; 
$config['full_tag_open'] = '<div id="pagination">'; 
$config['full_tag_close'] = '</div>'; 
$this->pagination->initialize($config); 

我越來越喜歡這個數據塊從控制器。哪一個也有效。

$data['stores'] = $this->stores_model->getChunks($config['per_page'], $this->uri->segment(2)); 

我的看法頁面有:

<?php echo $this->pagination->create_links(); ?> 

現在一切工作正常。首先顯示10個分頁鏈接,但是當我點擊鏈接8,9或10等時,分頁鏈接膨脹。它現在顯示鏈接1到20.爲什麼?這可能是非常簡單的事情,但似乎無法弄清楚。我期待的滾動分頁鏈接類型,但只顯示10個鏈接,因爲我已經在配置中設置。

感謝和問候

迪帕克

回答

0

現在我明白了

$配置[ 'NUM_LINKS']讓我困惑了一段時間。

這意味着要在當前鏈接的兩側(上一個和下一個)顯示的鏈接數量。

ie. (show prev 10 links from current) <----- [current page] -----> (show next 10 links from current) 

設置爲5解決了問題。按照預期,現在我總共有大約11個鏈接顯示。

再次感謝

迪帕克