FCKeditor is a WYSIWYG web editor that is often used as a background editor for publishing information. When you want to publish a lot of content is very long, you need to consider the front page of the paging effect, this article will use jquery, and in combination with PHP, FCKeditor published content to pagination, and implementation of the No Refresh switch page.
On the use of FCKeditor, I do not want to say. This article assumes that you are a web developer who has knowledge of jquery and PHP, and is familiar with the configuration and use of FCKeditor.
The FCKeditor editor has a function button to insert a page break, and clicking the button inserts a page break in the content area, as shown in the red box below:
Page breaks correspond to the generated HTML code:
<div style= "page-break-after:always" ><span style= "Display:none" > </span></div>
Our actual application is this: backstage through the FCKeditor editor published content, submitted to the database, the front desk through the PHP linked database to obtain the content of the publication, and then the long content to be divided, and to page.
Php
The way PHP divides content is as follows:
Function pagebreak ($content) { $content = $content; $pattern = "/<div style=\" page-break-after: always\ "><span style=\" display: none\ "> <\/span><\/div>/"; $strSplit = preg_split ($pattern, $content, -1, preg_split_no_empty) ; $count = count ($strSplit); $OUTSTR = ""; $i
= 1; if ($count > 1 ) { $outStr = "<div id= ' Page_break '" > "; foreach ($strSplit as $value) { &NBSP;&Nbsp; if ($i <= 1) { $outStr = "<div id= ' page_$i ' > $value </div>"; } else { $outStr .= "<div id= ' page_$i ' class= '" Collapse ' > $value </div> '; } $i ++; } $outStr .= "<div class= ' num ' >"; for ($i = 1; $i &NBSP;≪= $count; $i + +) { $OUTSTR .= "<li> $i </li>"; }
$outStr .= "</div></div>"; return $outStr; } else { return $content;
} }
As you can see, the $pattern in the code above is the page break code generated by the FCKeditor editor, and then PHP uses the Preg_split () function to compare the content to the separator, dividing the content into multiple Page_ and the raw page navigation button. Just call PageBreak ($content) when you use it.
Css
We use CSS to render the style of pagination buttons, of course you can modify these CSS to customize the look you want.
#page_break {}
#page_break. Collapse {Display:none}
#page_break. num {padding:10px 0;text-align:center;}
#page_break. Num li{display:inline; margin:0 2px;padding:3px 5px;border:1px solid #abcee4;
Background-color: #fff; color: #369; text-align:center;cursor:pointer;overflow:hidden;}
#page_break. Num li.on{background-color: #369; color: #fff; font-weight:bold;}
Jquery
$ (function () { $ (' #page_break .num li:first '). addclass (' on '); $ (' #page_break .num li '). Click (function () { //Hide All Page content $ ("#page_ break div[id^= ' Page_ '). Hide (); //Displays the contents of the current page. if ($ (this). Hasclass (' on ')) { $ (' #page_break #page_ ' + $ ( This). Text (). Show (); } else { $ (' #page_break .num li '). Removeclass (' on '); $ (this). AddClass (' on '); &NBSP;&NBSP;&NBsp; $ (' #page_break #page_ ' + $ (This). Text ( ). FadeIn (' normal '); } });
});
We use jquery to set the first page of the pager button to the current state, and then click the page-splitting button to toggle the button's status and display the contents of the corresponding page.
By the way, the title of the article is no refresh, in fact, this is not Ajax without refreshing effect, but through jquery control the content of the page display and hide, the page content is a one-time read load.