This article describes the CI paging class home page, the last page does not show the solution. Share to everyone for your reference, specific as follows:
Look at the manual said, every time to write again. Some $config, you can create a new file into the Config folder under, consider, config This folder system will automatically load, that is, no matter what page you visit this folder all the information will be loaded, so, To write in this file, you need to write a method so that it does not matter if the load is not loaded. I do not follow the instructions in the manual.
My idea: Since we are writing in the framework of CI, and each controller will introduce the parent class Ci_controller This class, all I have created a method in this class, the name page code is as follows:
The Public Function page ($url, $total, $pre, $status =true) {
$this->load->library (' pagination ');
$config [' base_url '] = $url;
$config [' total_rows '] = $total;
$config [' per_page '] = $pre;
$config [' page_query_string '] = $status;
$config [' first_link '] = ' first ';//home
$config [' first_tag_open '] = ';
$config [' first_tag_close '] = ';
$config [' last_link '] = ' last ';/end
$config [' last_tag_open '] = ';
$config [' last_tag_close '] = ';
$this->pagination->initialize ($config);
$page _list = $this->pagination->create_links ();
return $page _list;
}
Parameter description, $url: The address that you currently need to use for paging. $total: Total. $pre: The number of displays per page $status default is true to pass page in &page=1, and if modified to false, it is page/1 displayed.
Then use it directly in your controller as follows
$page _list = $this->page ("Http://XXX.XXXX.com/XXX/XXX", total, page display quantity);
Paging
This can be.
Tips: The system with the value of the parameter is not called page but pre_page as if, forget, because the parameter is too long, you are in the root directory-"system-->libraries--" pagination.php find var $query _string_segment = "Formal Parameters", modify the page here.
The test is to find that, if you follow the above wording, home and the last page does not show the reason: Your data is too small, pagination data at least 4 pages above will appear on the first page of this word, but we can modify, here I set to 3 pages to show, then also go to this pagination.php file to find
var $num _links = 2; This default is 2, which is the fourth page, the change to 1, note that the minimum can only be modified to 1, if you want to display in any case, you need to modify the code to find this code:
if ($this->first_link!== FALSE and $this->cur_page > ($this->num_links + 1))
The modification will remove all that follows and, since and is followed by the qualification, stating: $this->cur_page represents the current page, $this->num_links is to show when it is displayed, and there are other codes that are not shown here. Find your own under ask what $num_links cannot be set to 0
More interested in CodeIgniter related content readers can view the site topics: "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course", " Summary of PHP string usage, Introduction to PHP+MYSQL database operations, and a summary of PHP common database operations Tips
I hope this article will help you with the PHP program design based on CodeIgniter framework.