Solution for non-display of the CI paging homepage and the last page, ci Paging

Source: Internet
Author: User

Solution for non-display of the CI paging homepage and the last page, ci Paging

This example describes how to disable the display of the homepage and the last page of the CI paging class. We will share this with you for your reference. The details are as follows:

After reading the following manual, I have to re-write $ config every time. I can create a new file and put it under the config folder. After consideration, the config folder will be automatically loaded, that is to say, no matter what page you visit, all the information in this folder will be loaded. Therefore, to write in this file, you need to write a method, so that even if the file is not loaded, it does not matter. I have not followed the instructions in the manual.

My idea: Since we write something in the CI framework, and every controller introduces the class CI_Controller as the parent class, I have created a method in this class, the code for page name is 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 '; // homepage $ config ['first _ tag_open '] = ''; $ config ['first _ tag_close'] = ''; $ config ['last _ link'] = 'last'; // The end page $ 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 requires pagination. $ Total: total. $ Pre: number displayed on each page $ status is "true" by default. page is displayed in the & page = 1 mode. If it is changed to "false", it is displayed in the page/1 mode.

Then you can directly use the following in your controller:

$ Page_list = $ this-> page ("http://XXX.XXXX.com/XXX/XXX", total, page display count); // pagination

This is acceptable.

Tips: The value passing parameter provided by the system is not called page but pre_page. It seems that you forget that because the parameter is too long, you can go to the root directory -- "system --> libraries --" Pagination. in php, find var $ query_string_segment = "parameter". Modify the page here.

The test shows that if the homepage and the last page are not displayed according to the preceding statement: If your data volume is too small, at least four pages of paging data will appear on the homepage, but we can modify it. Here we set it to three pages for display, and we will also go to this pagination. find in PHP File

Var $ num_links = 2; The default value is 2, that is, the fourth page is displayed, and changed to 1. Note that the minimum value can be changed to 1, if you want to display it in any situation, you need to modify the code and find this Code:

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

Modify and to remove all the following, because and is followed by a condition. Note: $ this-> cur_page indicates the current page, $ this-> num_links indicates when it will be displayed. Other code is not described here. You cannot set it to 0 to find and ask what you want. $ num_links

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.