Provides various official and user-released code examples. For more information, see thinkphp paging with ellipsis.
Public function shows ()
{
$ Adjacents = 2;
If (0 = $ this-> totalRows) return '';
$ P = $ this-> varPage;
$ NowCoolPage = ceil ($ this-> nowPage/$ this-> rollPage );
// Analyze paging Parameters
If ($ this-> url ){
$ Depr = C ('url _ PATHINFO_DEPR ');
$ Url = rtrim (U ('/'. $ this-> url, ', false), $ depr). $ depr.' _ PAGE __';
} Else {
If ($ this-> parameter & is_string ($ this-> parameter )){
Parse_str ($ this-> parameter, $ parameter );
} Elseif (is_array ($ this-> parameter )){
$ Parameter = $ this-> parameter;
} Elseif (empty ($ this-> parameter )){
Unset ($ _ GET [C ('var _ URL_PARAMS ')]);
$ Var =! Empty ($ _ POST )? $ _ POST: $ _ GET;
If (empty ($ var )){
$ Parameter = array ();
} Else {
$ Parameter = $ var;
}
}
$ Parameter [$ p] = '_ PAGE __';
$ Url = U ('', $ parameter );
}
// Flip string
$ UpRow = $ this-> nowPage-1;
$ DownRow = $ this-> nowPage + 1;
// Previous Page
If ($ upRow> 0 ){
$ Pages. = "". $ this-> config ['prev']. "";
} Else {
$ Pages. = "". $ this-> config ['prev']. "";
}
// Page 1
If ($ this-> nowPage> ($ adjacents + 1 )){
$ Pages. = "1 ";
}
// Add ellipsis
If ($ this-> nowPage> ($ adjacents + 2 )){
$ Pages. = "...";
}
// 12345
$ Pmin = ($ this-> nowPage> $ adjacents )? ($ This-> nowPage-$ adjacents): 1;
$ Pmax = ($ this-> nowPage <($ this-> totalPages-$ adjacents ))? ($ This-> nowPage + $ adjacents): $ this-> totalPages;
For ($ I = $ pmin; $ I <= $ pmax; $ I ++ ){
If ($ I ==$ this-> nowPage ){
$ Pages. = "". $ I ."";
} Else {
$ Pages. = "". $ I ."";
}
}
// Add ellipsis
If ($ this-> nowPage <($ this-> totalPages-$ adjacents-1 )){
$ Pages. = "...";
}
// Last page
If ($ this-> nowPage <($ this-> totalPages-$ adjacents )){
$ Pages. = "totalPages, $ url)." '> ". $ this-> totalPages ."";
}
// Next page
If ($ downRow <= $ this-> totalPages ){
$ Pages. = "". $ this-> config ['Next']. "";
} Else {
$ Pages. = "". $ this-> config ['Next']. "";
}
Return $ pages;
}
Add to the paging class pure natural green pollution-free.
:
Attachment: http://www.esoxue.com/View/view/202.html
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB