Home >Backend Development >PHP Tutorial >THINKPHP content pagination code sharing_PHP tutorial

THINKPHP content pagination code sharing_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:01:43766browse

THINKPHP content paging code sharing

This article mainly shares with you a piece of THINKPHP content paging code for your own use. It is extracted from my project. It is very easy to use. It is recommended here. To my friends.

In a content management system developed using Thinkphp, many things must be developed by yourself. Of course, content paging must also be developed by yourself. Here is the method I compiled based on the information:

1. First, you need to insert page breaks when editing content in the background. The page breaks of different editors are naturally different

2. Then when reading the article content, the content must be divided into multiple arrays according to the page breaks. However, here you need to pass the value of which page the current page is, and read the divided array according to the page number

The code is as follows:

The code is as follows:



$arr_con=explode('_ueditor_page_break_tag_',$dy['art_content']);//Split content
$pagenum=count($arr_con);//Calculate the number of pages
//Determine the number of currently displayed pages based on the passed 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 cycled out
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 you use Thinkphp and configure staticization,

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

The above is for reference only, and it needs to be adjusted according to your specific project. I believe that friends can expand it very well.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/971929.htmlTechArticleTHINKPHP content paging code sharing This article mainly shares with you a section of THINKPHP content paging code for your own use, from my project Extracted from , it is very easy to use. I recommend it to children...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn