THINKPHP content paging code sharing, thinkphp paging sharing
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:
Copy code 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 there to be 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.
http://www.bkjia.com/PHPjc/942986.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/942986.htmlTechArticleTHINKPHP content paging code sharing, thinkphp paging sharing In the content management system developed using Thinkphp, many things need to be done by yourself Development and content paging must of course be developed by yourself...
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