2014-04-18 72 views
0

我正在構建一個圖像分級應用程序,其中主頁面基本上是一個圖像網格,每個圖像底部有簡單的「是/否」投票按鈕。沒有URI分段的Codeigniter分頁

我用笨的服務器端,引導(CSS和JS)的接口。現在

,我不想一次加載所有的圖像,而是分割圖像可達頁,包含10張圖片,以減少加載時間WACH頁。

我一直在尋找這要我利用這個代碼的變化的文檔@The CI Docs過來:

$this->load->library('pagination'); 

$config['base_url'] = 'imgapp.com'; 
$config['total_rows'] = 100; 
$config['per_page'] = 10; 

$this->pagination->initialize($config); 

echo $this->pagination->create_links(); 

產生這樣:

enter image description here

的問題是,我沒有以啓用URI段的方式構建它。

所以,鏈接是完全無用的 - 他們都指向這類的地址:

http://www.imgapp.com/default_controller/3

這對我來說是沒用的。

如何配置分頁以使用我的圖像應用程序?

回答

0

檢查http://ellislab.com/codeigniter/user-guide/libraries/pagination.html 配置分頁的關鍵是:

$config['uri_segment'] = 3; 
The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it. 

$config['base_url'] = 'http://example.com/index.php/test/page/'; 
base_url This is the full URL to the controller class/function containing your pagination. In the example above, it is pointing to a controller called "Test" and a function called "page". Keep in mind that you can re-route your URI if you need a different structure. 
+0

閱讀問題 - 我看着它。 – t0mgs