我正在用CodeIgniter和Twitter Bootstrap製作一個web應用程序。我在網上找到了一個包含$ config設置列表的資源,以正確設置分頁鏈接的樣式。有沒有辦法將它存儲在庫中並將其加載到控制器中,這樣我就不必每次都輸入它了?Codeigniter Bootstrap分頁
4
A
回答
18
您可以將此保存爲pagination.php應用/配置:
$config['per_page'] = 2;
$config['uri_segment'] = 3;
$config['num_links'] = 9;
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div><!--pagination-->';
$config['first_link'] = '« First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';
$config['last_link'] = 'Last »';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';
$config['next_link'] = 'Next →';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '← Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';
$config['anchor_class'] = 'follow_link';
0
您可以隨時簡單地使用settings數組創建一個.php
文件,並在您的模型中創建require_once()
文件並返回到分頁啓動器。或者,最好創建一個將所有設置返回給您的模型/庫。
型號:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
$pagination_config = array(
'full_tag_open' = '<p>',
'full_tag_close' = '</p>',
// ...
);
class Pagiconf extends CI_Model {
public function load() {
$this->load->library('pagination');
$this->pagination->initialize($config);
return $this->pagination->create_links();
}
}
你需要的地方吧:
$this->load->model('pagiconf');
echo $this->pagiconf->load();
4
的引導非常簡單的解決方案和codeigniter
$this->load->model('reciever');
$this->load->library('uri');
$this->load->library('pagination');
$config['base_url'] = base_url(). 'users_ci/users';
$config['total_rows'] = $this->reciever->getRows();
$config['per_page'] = 4;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config["num_links"] = round($config["total_rows"]/$config["per_page"]);
$config['users']= $this->reciever->getUsers(4,$this->uri->segment(3));
$this->pagination->initialize($config);
$config['pages'] = $this->pagination->create_links();
$this->load->view('users',$config);
和視圖你有
<div><?php echo $pages; ?></div>
+0
我寫過關於Cdeigniter分頁的教程。請看看並提出建議https://www.cloudways.com/blog/pagination-in-codeigniter/ –
0
The bellow working fine
$config["base_url"] = base_url() . "product/product/index1";
$config["total_rows"] = $count_products;
$config['per_page'] = 2;
$config['uri_segment'] = 4;
$config['num_links'] = 9;
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div><!--pagination-->';
$config['first_link'] = '« First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';
$config['last_link'] = 'Last »';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';
$config['next_link'] = 'Next →';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '← Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
0
這裏是引導V4.0
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] ='</ul>';
$config['num_tag_open'] = '<li class="page-item">';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li class="page-item"><a href="#" aria-label="Next">';
$config['next_tagl_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tagl_close'] = '</li>';
$config['first_tag_open'] = '<li class="page-item disabled">';
$config['first_tagl_close'] = '</li>';
$config['last_tag_open'] = '<li class="page-item"><a href="#" aria-label="Next">';
$config['last_tagl_close'] = '</a></li>';
$config['attributes'] = array('class' => 'page-link');
相關問題
- 1. Codeigniter bootstrap搜索結果分頁丟失
- 2. 分頁codeigniter
- 3. Codeigniter count_all分頁
- 4. CodeIgniter分頁
- 5. ordonate分頁codeigniter
- 6. CodeIgniter的分頁
- 7. Codeigniter分頁
- 8. CodeIgniter分頁
- 9. Codeigniter分頁
- 10. Advance CodeIgniter分頁
- 11. jquery bootstrap分頁
- 12. 如何在CodeIgniter中使用Bootstrap樣式類進行分頁
- 13. Codeigniter的多頁分頁
- 14. codeigniter:分頁在ajax頁面
- 15. Codeigniter分頁編號
- 16. codeigniter中的分頁
- 17. codeigniter分頁查詢
- 18. codeigniter分頁定製
- 19. Codeigniter分頁段4
- 20. CodeIgniter分頁:uri段
- 21. Codeigniter與jQuery分頁
- 22. Codeigniter jquery分頁庫
- 23. Codeigniter搜索分頁
- 24. Codeigniter分頁問題
- 25. CodeIgniter分頁問題
- 26. CodeIgniter的分頁類
- 27. 使用codeigniter分頁
- 28. Codeigniter分頁錯誤
- 29. Bootstrap標籤頁分頁
- 30. Bootstrap表格分頁
很有用...謝謝:) –
@mpet ...我的工作代碼哇驚人和非常簡單的解決方案你節省了我的時間。我只是想發表這個問題。非常感謝你。 – Zohaib
非常感謝 - 完美的作品! – fjckls