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

支持的靜態地址如下:www.example.com/xxx-xxx- " /> 亚洲精品国产精麻豆久久99,亚洲 欧美 国产 综合 在线,男生J桶进女人P又色又爽又黄

天天躁日日躁狠狠躁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分頁,轉載需保留來源!

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

主站蜘蛛池模板: 在线看片韩国免费人成视频 | 在公交车上被JB草坏了被轮J了 | 亚洲精品无码专区在线播放 | 一个人在线观看免费高清视频在线观看 | 欧美视频毛片在线播放 | 国产又粗又黄又爽的大片 | 在线播放性xxx欧美 在线播放午夜理论片 | 亚洲欧美中文字幕网站大全 | 火影小南被爆羞羞网站 | 亚洲一级毛片免费在线观看 | 久久精品国产96精品亚洲 | 久久99这里只有精品 | 男人和女人一起愁愁愁很痛 | 日本漂亮妈妈7观整有限中 日本片bbbxxx | 亚洲性无码AV久久成人 | 超h高h肉h文教室生理课 | 看美女大腿中间的部分 | 国产成人亚洲精品无广告 | 好色女博士 | 色mimi| 伊人精品影院 | 99久久精品免费看国产一区二区三区 | 雪恋电影完整版免费观看 | 草草久久久无码国产专区全集观看 | 国产欧美另类久久久品 | 成人毛片一区二区三区 | 亚洲欧美中文字幕网站大全 | 亚洲免费成人 | 麻豆国产人妻欲求不满 | 久久re视频这里精品09首页 | 久热人人综合人人九九精品视频 | 亚洲欧美综合乱码精品成人网 | 欧美Av无码高清在线 | 青青草国产精品久久 | 人与禽交3d动漫羞羞动漫 | 欧美亚洲精品真实在线 | 91系列在线观看免费 | 久久精品人人做人人爽97 | 欧美亚洲日韩自拍高清中文 | 色女仆影院| 伊人久在线 |