【1】自己修改帝國(guó)cms默認(rèn)的分頁樣式(css),這樣做的好處是你不用去改動(dòng)帝國(guó)的核心文件,方便以后升級(jí)。
【2】自己動(dòng)手去修改帝國(guó)的分頁(php+css),帝國(guó)的分頁在e>class>下的t_functions.php這個(gè)文件里。
===============================================
列表頁模板[!–show.page–]:分頁導(dǎo)航(下拉式) 大概在10-98行;
列表頁模板[!–show.listpage–]:分頁導(dǎo)航(列表式) 在101-169行;
內(nèi)容頁模板(返回內(nèi)容分頁):分頁導(dǎo)航 在172-228行;
內(nèi)容頁模板(返回下拉式內(nèi)容分頁導(dǎo)航):標(biāo)題式分頁導(dǎo)航 在231-262行。
===============================================
上面大概介紹了下這個(gè)文件下有那些分頁,那下面我們就來修改程序分頁,但是又不會(huì)在升級(jí)程序時(shí)候帶來麻煩。
第一步:進(jìn)入帝國(guó)cms后臺(tái),點(diǎn)擊系統(tǒng)設(shè)置->系統(tǒng)參數(shù)設(shè)置->信息設(shè)置:里面有個(gè)”列表分頁函數(shù)(列表)”選項(xiàng),將里面的函數(shù)名修改為user_ShowListMorePage
第二部:復(fù)制t_function.php列表式分頁代碼到 e/class/userfun.php 之間
下面我把分頁導(dǎo)航(列表式)拿出來,并帶上了注釋,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | //列表模板之列表式分頁 function sys_ShowListMorePage($num,$page,$dolink,$type,$totalpage,$line,$ok,$search="",$add){ global $fun_r,$public_r //num是取得的當(dāng)前總的文章數(shù),line是欄目設(shè)定里的一頁顯示多少文章數(shù)。如果當(dāng)前文章總數(shù)少于設(shè)定數(shù),中斷程序返回,并且什么也不顯示。 if($num<=$line) { $pager['showpage']=''; return $pager; } //文件名 if(empty($add['dofile'])) { $add['dofile']='index'; } //靜態(tài)頁數(shù) $repagenum=$add['repagenum']; //listpagelistnum是"系統(tǒng)參數(shù)設(shè)置" 里的 "信息設(shè)置" 下的 "列表分頁函數(shù)(列表)"下的 "每頁顯示12個(gè)頁碼"這一項(xiàng)。 $page_line=$public_r['listpagelistnum']; //這個(gè)$snum可以控制 "當(dāng)前頁" 顯示的位置,設(shè)置成2,當(dāng)前頁就顯示在第3個(gè)位置。 $snum=2; //$totalpage=ceil($num/$line);//取得總頁數(shù) $firststr='<a title="Total record">?<b>'.$num.'</b> </a>??';//顯示總文章數(shù) //上一頁 if($page<>1) { //若當(dāng)前頁不是第一頁,則顯示它的上一頁鏈接 //$dolink是欄目的地址,$type是網(wǎng)頁文件的擴(kuò)展名,比如 .html ,那個(gè)$type之前有個(gè)點(diǎn),是起連接作用的連接符,也就是說$type里面的內(nèi)容是 .html $toppage='<a href="'.$dolink.$add['dofile'].$type.'">'.$fun_r['startpage'].'</a>?'; $pagepr=$page-1; if($pagepr==1) { $prido=$add['dofile'].$type; } else { $prido=$add['dofile'].'_'.$pagepr.$type; } $prepage='<a href="'.$dolink.$prido.'">'.$fun_r['pripage'].'</a>'; } //下一頁 if($page!=$totalpage) { //如果當(dāng)前頁不是最后一頁,則顯示它的下一頁鏈接 $pagenex=$page+1; $nextpagelink=$repagenum&&$repagenum<$pagenex?eReturnRewritePageLink2($add,$pagenex):$dolink.$add['dofile'].'_'.$pagenex.$type; $lastpagelink=$repagenum&&$repagenum<$totalpage?eReturnRewritePageLink2($add,$totalpage):$dolink.$add['dofile'].'_'.$totalpage.$type; $nextpage='?<a href="'.$nextpagelink.'">'.$fun_r['nextpage'].'</a>'; $lastpage='?<a href="'.$lastpagelink.'">'.$fun_r['lastpage'].'</a>'; } //通過判斷當(dāng)前頁碼與上面講述的snum的大小,確定頁碼顯示的狀態(tài)。如果$page-$snum<1,$starti賦值為1,否則$starti賦值為$page-$snum。 $starti=$page-$snum<1?1:$page-$snum; $no=0; //此處的for循環(huán)就是用來顯示頁碼的,包括從第幾個(gè)頁碼開始顯示,以及當(dāng)前頁碼加粗和顯示多少個(gè)頁碼 for($i=$starti;$i<=$totalpage&&$no<$page_line;$i++) { $no++; //如果是當(dāng)前頁碼,則加粗,有需要修改當(dāng)前頁碼樣式的可在此修改 if($page==$i) { $is_1="<b>"; $is_2="</b>"; } //如果當(dāng)前頁是首頁 elseif($i==1) { $is_1='<a href="'.$dolink.$add['dofile'].$type.'">'; $is_2="</a>"; } //其余的頁碼,可以通過給a加樣式來修改顯示效果 else { $thispagelink=$repagenum&&$repagenum<$i?eReturnRewritePageLink2($add,$i):$dolink.$add['dofile'].'_'.$i.$type; $is_1='<a href="'.$thispagelink.'">'; $is_2="</a>"; } $returnstr.='?'.$is_1.$i.$is_2;//$returnstr即是生成的顯示頁號(hào)的代碼 } $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage; $pager['showpage']=$returnstr; return $pager; } |
下面我們就自己動(dòng)手弄一個(gè)分頁把:
第一步:進(jìn)入帝國(guó)cms后臺(tái),點(diǎn)擊系統(tǒng)設(shè)置->系統(tǒng)參數(shù)設(shè)置->信息設(shè)置:里面有個(gè)”列表分頁函數(shù)(列表)”選項(xiàng),將里面的函數(shù)名修改為user_ShowListMorePage
第二部:到 e/class/userfun.php 之間插入下面代碼
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | function user_ShowListMorePage($num,$page,$dolink,$type,$totalpage,$line,$ok,$search=""){ global $fun_r,$public_r; if($num<=$line) { $pager['showpage']=''; return $pager; } $page_line=$public_r['listpagelistnum']; $snum=2; //上一頁 if($page<>1) { $toppage='<a class="disabled" href="'.$dolink.'index'.$type.'">'.$fun_r['startpage'].'</a>'; //首頁 $pagepr=$page-1; if($pagepr==1) { $prido="index".$type; } else { $prido="index_".$pagepr.$type; } $prepage='<a class="disabled" href="'.$dolink.$prido.'">'.$fun_r['pripage'].'</a>'; //上一頁 } //下一頁 if($page!=$totalpage) { $pagenex=$page+1; $nextpage='<a class="disabled" href="'.$dolink.'index_'.$pagenex.$type.'">'.$fun_r['nextpage'].'</a>'; //下一頁 $lastpage='<a class="disabled" href="'.$dolink.'index_'.$totalpage.$type.'">'.$fun_r['lastpage'].'</a>'; //最后一頁 } $starti=$page-$snum<1?1:$page-$snum; $no=0; for($i=$starti;$i<=$totalpage&&$no<$page_line;$i++) //詳細(xì)頁碼信息 { $no++; if($page==$i) { $is_1="<a class="cur">"; //當(dāng)前 $is_2="</a>"; } elseif($i==1) { $is_1='<a href="'.$dolink.'index'.$type.'">'; //第一頁 $is_2="</a>"; } else { $is_1='<a href="'.$dolink.'index_'.$i.$type.'">'; //其他頁 $is_2="</a>"; } $returnstr.=$is_1.$i.$is_2; } $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage; $pager['showpage']=$returnstr; return $pager; } |
第三步:在你的列表頁中寫上分頁就好了【[!–show.listpage–]】
=============================================================
下面就來看看我最后的成果把
1 | <div class="pageBox pTB20"><a class="cur">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a><a href="/liaotian/index_6.html">6</a><a href="#">7</a><a href="#">8</a><a href="#" class="disabled">下一頁</a><a href="#" class="disabled">尾頁</a></div> |
css:
1 2 3 4 5 6 7 8 | /*** page -------------------------------------------------------------- ****/ .pageBox {text-align: center;} .pageBox a {border:1px solid #ddd;display:inline-block;margin-right:6px;color: #707070;width:34px;height:34px;font:bold 14px/34px arial;} .pageBox a:hover,.pageBox a:active{background:#3aa9f2;color: #FFFFFF;text-decoration: none;} .pageBox .cur { background: #3aa9f2;border: 1px solid #3aa9f2;text-decoration: none;} .pageBox a.cur {color: #fff;} .pageBox .disabled {width: 79px;} |
新聞熱點(diǎn)
疑難解答
圖片精選