Example of pagination in php KindEditor

Source: Internet
Author: User
Tags explode fast web

My understanding of core code

The code is as follows: Copy code

$ News = array (
'Title' => 'first ',
'Content' => '<p> this is paragraph 1 </p>'
. '<P> this is paragraph 2 </p>'
. 'Now I make a page end. [-- page --] page 2 start ~~~~~ '
);

$ NewsModel-> insert ($ news );
======================================

// News_detail.php? P = 2:

$ News_one = $ newsModel-> get (1 );

$ Content_pages = explode ('[-- page --]', $ news_one ['content']);

$ Cur_page = min (max (1, intval ($ _ GET ['P']), count ($ content_pages ));

$ News_one ['content'] = $ content_pages [$ cur_page-1];

Return render('news_detail.html ', $ news_one );

We know that many online editors have the page insertion function. For example, clicking Insert page editor in KindEditor inserts the following code at the cursor position:

The code is as follows: Copy code
<Hr style = "page-break-after: always;" class = "ke-pagebreak"/>

UEditor adds the following content to the cursor:

There is no space between _ ueditor_page _ break_tag _ ueditor_page and _ break_tag _. Because the website also uses the ueditor's paging character break_tag, spaces are added above to avoid impact.

Next I will use KindEditor as an example to paste my code:

The code is as follows: Copy code

<! Doctype html>
<Html lang = "en">
<Head>
<Meta charset = "UTF-8">
<Title> Document </title>
</Head>
<Body>
<? Php
$ Content = <str
<P> Shanghai Dingxiang Information Technology Co., Ltd. (TOPThink Inc .) as a leading WEB application and service provider in China, Alibaba Cloud is committed to the R & D and service of WEB application platforms, products and applications, and provides enterprises and institutions with fast WEB-based application development solutions and products. Founded in September 2008, the company is a high-tech enterprise with independent intellectual property rights. </P>
<Hr/>
<P> The company has been focusing on WEB application frameworks, application platforms, and enterprise solutions for a long time. The company's core technical framework ThinkPHP was founded in 2006 by founder Liu Chen, after more than six years of meticulous creation and development, it has a broad user base and a good reputation in the industry and has grown into the leading and most influential WEB application development framework in China, foreign countries also have considerable advantages over the same period of time. Its application fields are distributed in various industries and have excellent support and expansion in the portal, community, and e-commerce fields. There are no more than a thousand cases, it has great advantages in terms of security, efficiency, and load. It has become a quick development solution and best practice for WEB applications! </P>
<Hr/>
<P>
Headquartered in Shanghai, the company is led by senior experts who have been engaged in Internet and user experience research for 10 years. It has a group of professional planning, design and technical teams and a wide range of community technical forces. For a long time, the company has invited a large number of security and project experts as consultants to ensure the development and implementation of customer projects. The company also has a senior user experience and design research team, tailored to different users user experience process, has a good product design and design concepts. <Br/> in September 2009, he was recommended for a major project in Shanghai. </P>
Str;

$ Content = preg_replace ("'$ Content = explode ("$ Count = count ($ content );
$ P = empty ($ _ GET ['Page'])? 1: (int) $ _ GET [page];
$ P = 0? 1: $ p;
$ P = $ p> $ count? $ Count: $ p;
$ P --;
$ Content = $ content [$ p];
$ P ++;
If ($ count> 1 ){
$ Page = '<a class = "first" href = "? Page = 1 "> homepage </a> ';
For ($ I = 1; $ I <= $ count; $ I ++ ){
$ Page. = $ I = $ p? '[<A class = "on" style = "color: red;" href = "javascript: void (0)"> '. $ I. '</a>]': '[<a href = "? Page = '. $ I.' "> '. $ I.' </a> ]';
    }
$ Page. = '<a class = "end" href = "? Page = '. $ count.' "> Last page </a> ';

}
Echo "Echo $ content;

Echo "<div >{$ page} </div> ";

?>
</Body>
</Html>

According to the above code, you can implement the article paging, as shown in the figure below:

If you use the UEditor editor paging operator: _ ueditor_page _ break_tag _ (you can go to ueditor. config. modify the settings of pageBreakTag in js), then you can slightly modify the above code:

The code is as follows: Copy code

$ Content = preg_replace ("'$ Content = explode ("

Changed:

$ Content = explode ("_ ueditor_page _ break_tag _", $ content );

In this way, you can customize any page break.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.