Content page pagination code, pagination code _php tutorial

Source: Internet
Author: User

Content page pagination code, pagination code


In the use of thinkphp development of the content management system inside, a lot of things to develop their own, the content of course also to develop their own, the following is my data according to check the method of self-collation:

1, the first is to edit content in the background when you need to insert a page break, different editor page breaks are naturally different

2, then is to read the content of the article, according to the page to divide the content into multiple arrays, where the value of the current is the number of pages, according to the number of pages to read the segmented array

The code is as follows:

     
  $arr _con=
  Explode(' _ueditor_page_break_tag_ ',
  $dy[' art_content ']);
  //
  Split Content    
  $pagenum=
  Count(
  $arr _con);
  //
  count Pages//determine the number of pages currently displayed based on value    
  if(
  intval(
  $_get[' P ']) ==0
  ){    
  $p=1
  ; }
  Else
  {    
  $p=
  intval(
  $_get[' P '
  ]); }    
  //
  get 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 looped out    
   for(
  $i= 1;
  $i<=
  $pagenum;
  $i++
  ){    
  if(
  $i==
  $p
  ){        
  $show.='
  $i.']'
  ; }    
  Else
  {        
  $show. = ' $url.' &p= '.
  $i.'" >['.
  $i.']'
  ; }                             }    
  //
  dump ($arr _con);    
  $show=
  $pagenum==1? ':
  $show;
  //
  Pagination Code display judgment     
 {$arr _con[$p-1]}
 

Note: If you are using thinkphp, and you have configured static,

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

The above is for reference only, in particular, according to their own specific projects to adjust

http://www.bkjia.com/PHPjc/942274.html www.bkjia.com true http://www.bkjia.com/PHPjc/942274.html techarticle content page pagination code, pagination code in the use of thinkphp developed content management system inside, a lot of things to develop their own, content paging of course, also to develop their own, the following is my root ...

  • Related Article

    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.