Content page pagination code, pagination code_PHP tutorial

WBOY
Release: 2016-07-13 10:09:48
Original
1233 people have browsed it

Content page paging code, paging code

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. The following 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:

<php>
    <span>$arr_con</span>=<span>explode</span>('_ueditor_page_break_tag_',<span>$dy</span>['art_content']);<span>//</span><span>分割内容</span>
    <span>$pagenum</span>=<span>count</span>(<span>$arr_con</span>);<span>//</span><span>计算页数
    //根据传值判断当前显示页数</span>
    <span>if</span>(<span>intval</span>(<span>$_GET</span>['p'])==0<span>){
    </span><span>$p</span>=1<span>;
    }</span><span>else</span><span>{
    </span><span>$p</span>=<span>intval</span>(<span>$_GET</span>['p'<span>]);
    }
    </span><span>//</span><span>获得当前页的url</span>
    <span>$url</span>  =  <span>$_SERVER</span>['REQUEST_URI'].(<span>strpos</span>(<span>$_SERVER</span>['REQUEST_URI'],'?')?'':"?"<span>);
    </span><span>$parse</span> = <span>parse_url</span>(<span>$url</span><span>);
    </span><span>if</span>(<span>isset</span>(<span>$parse</span>['query'<span>])) {
        </span><span>parse_str</span>(<span>$parse</span>['query'],<span>$params</span><span>);
        </span><span>unset</span>(<span>$params</span>['p'<span>]);
        </span><span>$url</span>   =  <span>$parse</span>['path'].'?'.<span>http_build_query</span>(<span>$params</span><span>);
    }
    </span><span>//</span><span>有多少页都全部循环出来</span>
    <span>for</span>(<span>$i</span>=1;<span>$i</span><=<span>$pagenum</span>;<span>$i</span>++<span>){
    </span><span>if</span>(<span>$i</span>==<span>$p</span><span>){
        </span><span>$show</span>.='<span>$i</span>.']</span>'<span>;
    }
    </span><span>else</span><span>{
        </span><span>$show</span>.='<a href="'.<span>$url</span>.'&p='.<span>$i</span>.'">['.<span>$i</span>.']</a>'<span>;
    }
                         
    }
    </span><span>//</span><span> dump($arr_con);</span>
    <span>$show</span>=<span>$pagenum</span>==1?'':<span>$show</span>;<span>//</span><span>分页代码显示判断</span>
     
</php><span>
{</span><span>$arr_con</span>[<span>$p</span>-1]}<!--这里是刚进入这篇文章显示的数据,数组键值从0开始-->
Copy after login

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 needs to be adjusted according to your specific project

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/942274.htmlTechArticle Content page pagination code. In the content management system developed using Thinkphp, many things need to be developed by yourself. Of course, content pagination must be developed by yourself. The following is my root...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template