上一篇(帝国cms 列表页分页样式修改美化【1】)中我们已经对分页说了一个大概,下面我们就自己动手弄一个分页把:
第一步:进入帝国cms后台,点击系统设置->系统参数设置->信息设置:里面有个"列表分页函数(列表)"选项,将里面的函数名修改为user_ShowListMorePage
第二部:到 e/class/userfun.php <?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 href="‘.$dolink.‘index‘.$type.‘" class="disabled">‘.$fun_r[‘startpage‘].‘</a>‘; //首页 $pagepr=$page-1; if($pagepr==1) { $prido="index".$type; } else { $prido="index_".$pagepr.$type; } $prepage=‘<a href="‘.$dolink.$prido.‘" class="disabled">‘.$fun_r[‘pripage‘].‘</a>‘; //上一页 } //下一页 if($page!=$totalpage) { $pagenex=$page+1; $nextpage=‘<a href="‘.$dolink.‘index_‘.$pagenex.$type.‘" class="disabled">‘.$fun_r[‘nextpage‘].‘</a>‘; //下一页 $lastpage=‘<a href="‘.$dolink.‘index_‘.$totalpage.$type.‘" class="disabled">‘.$fun_r[‘lastpage‘].‘</a>‘; //最后一页 } $starti=$page-$snum<1?1:$page-$snum; $no=0; for($i=$starti;$i<=$totalpage&&$no<$page_line;$i++) //详细页码信息 { $no++; if($page==$i) { $is_1="<a class=‘cur‘>"; //当前 $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--]】
=============================================================
下面就来看看我最后的成果把

我们在来看看代码结构
<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代码
/*** 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;}
原文:http://www.cnblogs.com/huige728/p/3538200.html