THINKPHP content paging code sharing, thinkphp paging sharing _ PHP Tutorial

Source: Internet
Author: User
The THINKPHP content is shared by page code and thinkphp by page. THINKPHP content page-by-page code sharing. thinkphp page-by-page sharing is used in the content management system developed by Thinkphp. many THINKPHP content must be developed by yourself. the THINKPHP content page-by-page code sharing must also be developed by yourself, thinkphp paging sharing

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.

In the content management system developed using Thinkphp, ghost needs to develop many things by itself, and content paging needs to be developed by itself...

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.