Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the first page and the last page of the CI paging class are not displayed?

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the CI paging class home page, the end page does not show how to do, the article introduces in great detail, has a certain reference value, interested friends must read it!

Read the manual and said that every time to write some $config, you can create a new file under the config folder, consider that config this folder system will automatically load, that is to say, no matter what page you visit this folder all the information will be loaded, so, if you want to write in this file you need to write method, so that even if you load if you do not load it does not matter. I did not follow the words in the manual.

My idea: since we are writing under the framework of CI, and every controller introduces the parent class CI_Controller, I create 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';// homepage $config [' first_tag_open'] ='; $config ['first_tag_close'] ='' $config ['last_link'] =' Last';// last 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: currently needs to use a paged address. $total: total. $pre: the number displayed per page $status defaults to true passing page to & page=1, and if modified to false, it has been displayed in page/1.

Then use it directly in your controller as follows

$page_list = $this- > page ("Total number of http://XXX.XXXX.com/XXX/XXX", number of pages displayed); / / pagination

That's fine.

Tips: the parameter passed by the system is not called page but pre_page. It seems that because the parameter is too long, you can find var $query_string_segment = "parameter" in the root directory-- "system-- > libraries--" Pagination.php; you can modify page here.

The test found that if according to the above writing, the first page and the last page do not display the reason: your amount of data is too small, paging data at least more than 4 pages will appear the word "home page", but we can modify, here I set to 3 pages to display, then also go to this pagination.php file to find

Var $num_links = 2; the default is 2, which is displayed on page 4. Change it to 1. Note that it can only be changed to 1 at least. If you want to display it in any case, 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 remove everything after and, because and is followed by a qualification. Explain below: $this- > cur_page indicates the current page, and $this- > num_links is to be displayed when it will be displayed. There are other codes that are not explained here. Find out why $num_links cannot be set to 0.

These are all the contents of this article entitled "what to do if the first page and the last page of the CI page are not displayed". Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report