Table of Contents
Content page paging code, paging code
Home Backend Development PHP Tutorial Content page pagination code, pagination code_PHP tutorial

Content page pagination code, pagination code_PHP tutorial

Jul 13, 2016 am 10:09 AM
thinkphp thing code use content Pagination exist develop of management system Own

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>&lt;=<span>$pagenum</span>;<span>$i</span>++<span>){
    </span><span>if</span>(<span>$i</span>==<span>$p</span><span>){
        </span><span>$show</span>.='&lt;span>$i</span>.']&lt;/span&gt;'<span>;
    }
    </span><span>else</span><span>{
        </span><span>$show</span>.='&lt;a href="'.<span>$url</span>.'&amp;p='.<span>$i</span>.'"&gt;['.<span>$i</span>.']&lt;/a&gt;'<span>;
    }
                         
    }
    </span><span>//</span><span> dump($arr_con);</span>
    <span>$show</span>=<span>$pagenum</span>==1?'':<span>$show</span>;<span>//</span><span>分页代码显示判断</span>
     
&lt;/php&gt;<span>
{</span><span>$arr_con</span>[<span>$p</span>-1]}&lt;!--这里是刚进入这篇文章显示的数据,数组键值从0开始--&gt;
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...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

Four recommended AI-assisted programming tools

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

How to use Baidu Netdisk app

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

How to use NetEase Mailbox Master

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?

See all articles