1】自己修改帝国cms默认的分页样式(css),这样做的好处是你不用去改动帝国的核心文件,方便以后升级。
【2】自己动手去修改帝国的分页(php+css),帝国的分页在e>class>下的t_functions.php这个文件里。
===============================================
列表页模板[!--show.page--]:分页导航(下拉式) 大概在10-98行;
列表页模板[!--show.listpage--]:分页导航(列表式) 在101-169行;
内容页模板(返回内容分页):分页导航 在172-228行;
内容页模板(返回下拉式内容分页导航):标题式分页导航 在231-262行。
===============================================
上面大概介绍了下这个文件下有那些分页,那下面我们就来修改程序分页,但是又不会在升级程序时候带来麻烦。
第一步:进入帝国cms后台,点击系统设置->系统参数设置->信息设置:里面有个"列表分页函数(列表)"选项,将里面的函数名修改为user_ShowListMorePage
第二部:复制t_function.php列表式分页代码到 e/class/userfun.php <?php ?> 之间
下面我把分页导航(列表式)拿出来,并带上了注释,如下:
第一步:进入帝国cms后台,点击系统设置->系统参数设置->信息设置:里面有个"列表分页函数(列表)"选项,将里面的函数名修改为user_ShowListMorePage
第二部:到 e/class/userfun.php <?php ?> 之间插入下面代码
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;}