目前此分頁支持靜態化地址分頁和無鏈接地址時的ajax分頁(但是js得自己寫):

支持的靜態地址如下:www.example.com/xxx-xxx- " /> 久久久久久久久一区二区,精品亚洲成人,91视频在线观看

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

php頁碼形式分頁函數支持靜態化地址及ajax分頁

之前每次遇到分頁,總是得自己寫,覺得挺繁瑣的,所以本著通用的原則,寫了一個分頁的方法,特此記錄。

目前此分頁支持靜態化地址分頁和無鏈接地址時的ajax分頁(但是js得自己寫):

支持的靜態地址如下:www.example.com/xxx-xxx-p1-xxxx-xx.html

其他形式靜態化需根據自己情況進行改寫

支持ajax方式分頁時,$link參數為空,但提供了pid和optype,其中pid用于獲取該頁碼頁數,optype用于一個頁面存在多個分頁時區分當前觸發動作屬于哪個分頁邏輯
復制代碼 代碼如下:
/**********************************************************
*
* 獲取頁碼
*
**********************************************************
*
* @params string $link 鏈接地址(鏈接為空時可以用ajax翻頁)
*
* @params int $intPage 當前頁數
*
* @params int $intTotal 總頁數
*
* @params int $intSize 要顯示的頁數個數
*
* @params string $type 鏈接種類(多個翻頁用于區分翻頁區域)
*
**********************************************************
*
* @return array
*/
private function formatPage($link="",$intPage,$intTotal,$intSize=3,$type="")
{
$strPage = '<div class="g_serpage clearfix">';
if($intTotal > 0)
{
if($intPage > 1)
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".($intPage-1),$link).'"><<</a>':'<a optype="'.$type.'" pid="showpage_'.($intPage-1).'" href="Javascript:void(0)"><<</a>';
else
$strPage .= '<a href="Javascript:void(0)"><<</a>';
//窗口寬度大于等于總頁數
if( ($intSize+2) >= $intTotal )
{
for($i=1;$i<=$intTotal;$i++)
{
$strClass = $i == $intPage ? 'class="g_serpagcur"' : "";
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".$i,$link).'" '.$strClass.'>'.$i.'</a>':'<a optype="'.$type.'" pid="showpage_'.$i.'" href="Javascript:void(0)" '.$strClass.'>'.$i.'</a>';
}
}
else
{
if($intPage < ceil($intSize/2))
{
for($i=1;$i<=$intSize;$i++)
{
$strClass = $i == $intPage ? 'class="g_serpagcur"' : "";
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".$i,$link).'" '.$strClass.'>'.$i.'</a>':'<a optype="'.$type.'" pid="showpage_'.$i.'" href="Javascript:void(0)" '.$strClass.'>'.$i.'</a>';
}
$strPage .= $link!=''?'<a class="gpage_nobor" >…</a><a href="'.preg_replace("/-p(/d+)/","p".$intTotal,$link).'" >'.$intTotal.'</a>':'<a class="gpage_nobor" >…</a><a optype="'.$type.'" pid="showpage_'.$intTotal.'" href="Javascript:void(0)" >'.$intTotal.'</a>';
}
elseif(($intTotal-$intPage) < ceil($intSize/2))
{
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p1",$link).'">1</a><a class="gpage_nobor" >…</a>':'<a optype="'.$type.'" pid="showpage_1" href="Javascript:void(0)">1</a><a class="gpage_nobor" >…</a>';
for($i = ($intTotal + 1 - $intSize);$i++;$i<=$intTotal)
{
$strClass = $i == $intPage ? 'class="g_serpagcur"' : "";
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".$i,$link).'" '.$strClass.'>'.$i.'</a>':'<a optype="'.$type.'" pid="showpage_'.$i.'" href="Javascript:void(0)" '.$strClass.'>'.$i.'</a>';
}
}
else
{
$intOffset = floor($intSize/2);
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p1",$link).'">1</a>':'<a optype="'.$type.'" pid="showpage_1" href="Javascript:void(0)">1</a>';
if( ($intPage - $intOffset) > 2)
{
$strPage .= '<a class="gpage_nobor" >…</a>';
}
for($i=(($intPage - $intOffset)<=1?2:($intPage - $intOffset));$i<=(($intPage + $intOffset)>=$intTotal?($intTotal-1):($intPage + $intOffset));$i++)
{
$strClass = $i == $intPage ? 'class="g_serpagcur"' : "";
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".$i,$link).'" '.$strClass.'>'.$i.'</a>':'<a optype="'.$type.'" pid="showpage_'.$i.'" href="Javascript:void(0)" '.$strClass.'>'.$i.'</a>';
}
if( ($intPage - $intOffset) < ($intTotal - 1))
{
$strPage .= '<a class="gpage_nobor" >…</a>';
}
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".$intTotal,$link).'">'.$intTotal.'</a>':'<a optype="'.$type.'" pid="showpage_'.$intTotal.'" href="Javascript:void(0)">'.$intTotal.'</a>';
}
}
if($intPage < $intTotal)
{
$strPage .= $link!=''?'<a href="'.preg_replace("/-p(/d+)/","p".($intPage+1),$link).'">>></a>':'<a optype="'.$type.'" pid="showpage_'.($intPage+1).'" href="Javascript:void(0)">>></a>';
}
else
{
$strPage .= '<a href="Javascript:void(0)">>></a>';
}
}
$strPage .= "</div>";
return $strPage;
}

php技術php頁碼形式分頁函數支持靜態化地址及ajax分頁,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 午夜免费网 | 中文字幕一区二区三区四区 | 国产精品欧美一区二区 | 亚洲成人免费视频在线观看 | 国内精品久久久久久久 | 久久久久久国产 | 国产黄色精品 | 成人精品一区二区三区四区 | 一级毛片免费完整视频 | 日本不卡高字幕在线2019 | 成年人免费看的视频 | 人人九九精 | 日韩免费高清视频 | 精品久久久久久久久久久久久久久久久 | 伊人激情综合网 | 激情视频网站 | 午夜av在线 | 波多野结衣中文字幕一区二区三区 | 亚洲国产黄色av | 免费激情 | 久久综合狠狠综合久久 | 国产sm主人调教女m视频 | 国产91丝袜 | 久精品视频 | 黄色免费网 | 99精品国产一区二区青青牛奶 | 久久99久久99| jizz18国产| 亚洲不卡在线观看 | 精品一区二区电影 | 能看的av| 成人妇女免费播放久久久 | 麻豆av在线免费观看 | 亚洲综合在线视频 | 日韩精品一| 免费 视频 1级 | 日本免费一区二区三区四区 | 亚洲成人综合网站 | 国产精品亚洲综合 | 国产一区二区日韩 | 午夜精品久久久久久久久久久久久 |