Solution to the problem that the first and last pages of the CI paging class are not displayed, ci paging_PHP tutorial

WBOY
Release: 2016-07-12 08:55:05
Original
731 people have browsed it

The solution to the problem that the first and last pages of the CI paging class are not displayed, ci paging

The example in this article describes the solution to the problem that the first and last pages of the CI paging class are not displayed. Share it with everyone for your reference, the details are as follows:

After reading the manual, it said that you have to write the $config again every time. You can create a new file and put it under the config folder. After thinking about it, the system will automatically load the config folder, which means that no matter what All the information in the folder of whatever page you visit will be loaded. Therefore, if you want to write in this file, you need to write a method, so that it does not matter even if it is loaded but not loaded. I didn't follow what the manual said.

My idea: Since we are writing under the CI framework, and each controller will introduce the parent class CI_Controller, I created a method in this class with the name page code as follows:

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';//首页
  $config['first_tag_open'] = '';
  $config['first_tag_close'] = '';
  $config['last_link'] = 'Last';//尾页
  $config['last_tag_open'] = '';
  $config['last_tag_close'] = '';
  $this->pagination->initialize($config);
  $page_list = $this->pagination->create_links();
  return $page_list;
}

Copy after login

Parameter description, $url: The address that currently needs to be used for paging. $total: total number. $pre: The number displayed on each page. $status is true by default. The page is passed in the form of &page=1. If it is changed to false, it will be displayed in the form of page/1.

Then use it directly in your controller as follows

$page_list = $this->page("http://XXX.XXXX.com/XXX/XXX",总数,页显示数量);
//分页

Copy after login

That’s fine.

tips: The value-passing parameter that comes with the system is not called page but pre_page. I forgot, because the parameter is too long, you are in the root directory--"system-->libraries- -》In Pagination.php, find var $query_string_segment ="Formal parameter"; just modify the page here.

The test is to find out that if you follow the above writing method, the reason why the home page and last page are not displayed: your data volume is too small, and the word home page will not appear until at least 4 pages of paginated data, but we can modify it, here I If it is set to 3 pages, then go to the pagination.php file and find

var $num_links = 2; the default here is 2, which is only displayed on the fourth page. Change it to 1. Note that the minimum value here can only be changed to 1. If you want to display it under any circumstances, you need to modify the code. Find This code:

if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))

Copy after login

Modify and remove everything after and, because after and is the limiting condition, explain: $this->cur_page represents the current page, $this->num_links is when it will be displayed, and There are other codes that I won’t explain here. You can look it up yourself and ask why $num_links cannot be set to 0

Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php date and time usage summary", "php object-oriented program" Design introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

Articles you may be interested in:

  • Codeigniter (CI) framework paging function and related knowledge
  • CodeIgniter paging class pagination usage example
  • codeigniter implementation Get paging method
  • Codeigniter framework implements the method of getting paging data and total number of items
  • Example of paging class that passed the test in codeigniter
  • CodeIgniter assisted third-party class library third_party Usage analysis
  • Detailed explanation of CodeIgniter extended core class examples
  • php implementation of shopping cart class that imitates CodeIgniter
  • Codeigniter shopping cart class cannot add Chinese solutions
  • Use CodeIgniter’s class library to upload images
  • Use configuration classes to define Codeigniter global variables
  • Instructions on how to use codeigniter’s own database class
  • In-depth analysis of CodeIgniter image processing class

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1117096.htmlTechArticleThe solution to the problem that the first and last pages of the CI paging class are not displayed. The example of ci paging in this article tells the first and last pages of the CI paging class. Solution to the last page not being displayed. Share it with everyone for your reference, the details are as follows:...
Related labels:
ci
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template