THINKPHP content paging code sharing _ PHP Tutorial

Source: Internet
Author: User
The THINKPHP content is shared by page. THINKPHP content paging code sharing this article mainly shares with you a self-use THINKPHP content paging code that is extracted from my project and is very easy to use. Here we recommend the paging code sharing for THINKPHP content.

This article mainly shares with you a paging code of THINKPHP content for your own use. it is very easy to use and is recommended to your friends here.

In the content management system developed using Thinkphp, many things need to be developed by myself, and the content paging should also be developed by myself. The following is my method based on the query information:

1. the first step is to insert a paging character when editing the content in the background. different editor paging characters are naturally different.

2. when reading the content of an article, you need to split the content into multiple arrays based on the pagination character. here, you need to pass the value on the current page, reads the split array based on the number of pages

The code is as follows:

The code is as follows:



$ Arr_con = explode ('_ ueditor_page_break_tag _', $ dy ['Art _ content']); // split the content
$ Pagenum = count ($ arr_con); // calculate the number of pages
// Determine the number of currently displayed pages based on the pass value
If (intval ($ _ GET ['P']) = 0 ){
$ P = 1;
} Else {
$ P = intval ($ _ GET ['P']);
}
// Obtain the url of the current page
$ Url = $ _ SERVER ['request _ URI ']. (strpos ($ _ SERVER ['request _ URI'], '? ')? '':"? ");
$ Parse = parse_url ($ url );
If (isset ($ parse ['query']) {
Parse_str ($ parse ['query'], $ params );
Unset ($ params ['P']);
$ Url = $ parse ['path']. '? '. Http_build_query ($ params );
}
// How many pages are all cyclically displayed
For ($ I = 1; $ I <= $ pagenum; $ I ++ ){
If ($ I = $ p ){
$ Show. = '['. $ I. ']';
}
Else {
$ Show. = '['. $ I. ']';
}
}
// Dump ($ arr_con );
$ Show = $ pagenum = 1? '': $ Show; // paging code display judgment

{$ Arr_con [$ P-1]}



Note: If Thinkphp is used and static is configured,

Modify the configuration file 'news: article' => array ('{: module}/{: action }_{ art_id }_{ p}', 0), and add a p parameter.

The above is for reference only, but we also need to adjust it based on our specific projects. I believe our partners can extend it well.

Ghost This article mainly shares with you a paging code of THINKPHP content for your own use. it is very easy to use and is recommended to small ones here...

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.