帝国cms 列表页分页样式修改美化两种方法
【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   ?>  之间
下面我把分页导航(列表式)拿出来,并带上了注释,如下:
//列表模板之列表式分页
function sys_ShowListMorePage($num,$page,$dolink,$type,$totalpage,$line,$ok,$search="",$add){
    global $fun_r,$public_r
    //num是取得的当前总的文章数,line是栏目设定里的一页显示多少文章数。如果当前文章总数少于设定数,中断程序返回,并且什么也不显示。
    if($num<=$line)
    {
        $pager['showpage']='';
        return $pager;
    }
    //文件名
    if(empty($add['dofile']))
    {
        $add['dofile']='index';
    }
    //静态页数
    $repagenum=$add['repagenum'];
    //listpagelistnum是"系统参数设置" 里的 "信息设置" 下的 "列表分页函数(列表)"下的 "每页显示12个页码"这一项。
    $page_line=$public_r['listpagelistnum'];
    //这个$snum可以控制 "当前页" 显示的位置,设置成2,当前页就显示在第3个位置。
    $snum=2;
    //$totalpage=ceil($num/$line);//取得总页数
    $firststr='<a title="Total record"> <b>'.$num.'</b> </a>  ';//显示总文章数
    //上一页
    if($page<>1)
    {
        //若当前页不是第一页,则显示它的上一页链接
        //$dolink是栏目的地址,$type是网页文件的扩展名,比如 .html ,那个$type之前有个点,是起连接作用的连接符,也就是说$type里面的内容是  .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)
    {
        //如果当前页不是最后一页,则显示它的下一页链接
        $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>';
    }
    //通过判断当前页码与上面讲述的snum的大小,确定页码显示的状态。如果$page-$snum<1,$starti赋值为1,否则$starti赋值为$page-$snum。
    $starti=$page-$snum<1?1:$page-$snum;
    $no=0;
    //此处的for循环就是用来显示页码的,包括从第几个页码开始显示,以及当前页码加粗和显示多少个页码
    for($i=$starti;$i<=$totalpage&&$no<$page_line;$i++)
    {
        $no++;
        //如果是当前页码,则加粗,有需要修改当前页码样式的可在此修改
        if($page==$i)
        {
            $is_1="<b>";
            $is_2="</b>";
        }
        //如果当前页是首页
        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即是生成的显示页号的代码
    }
    $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
    $pager['showpage']=$returnstr;
    return $pager;
}
下面我们就自己动手弄一个分页把:
第一步:进入帝国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 | functionuser_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--]】
=============================================================
下面就来看看我最后的成果把.

我们在来看看代码结构
| 1 | <divclass="pageBox pTB20"><aclass="cur">1</a><ahref="#">2</a><ahref="#">3</a><ahref="#">4</a><ahref="#">5</a><ahref="/liaotian/index_6.html">6</a><ahref="#">7</a><ahref="#">8</a><ahref="#" class="disabled">下一页</a><ahref="#" class="disabled">尾页</a></div>  | 
下面是css代码
| 1 2 3 4 5 6 7 8 | /*** page-------------------------------------------------------------- ****/.pageBox {text-align: center;}.pageBox a {border:1pxsolid#ddd;display:inline-block;margin-right:6px;color: #707070;width:34px;height:34px;font:bold14px/34pxarial;}.pageBox a:hover,.pageBox a:active{background:#3aa9f2;color: #FFFFFF;text-decoration: none;}.pageBox .cur { background: #3aa9f2;border: 1pxsolid#3aa9f2;text-decoration: none;}.pageBox a.cur {color: #fff;}.pageBox .disabled {width: 79px;} | 







