dedecms分页显示代码并设置样式教程
dedecms分页代码默认是<li>分页数据</li>,这样为我们设置样式带来了一定的难度。在这里做了将 li 标签修改 a 标签,方便设置样式。需要修改的有两个文件
一、include/arc.archives.class.php 修改代码如下(注释部分为原有代码,紧跟后面的是修改后的代码)
- //获得静态页面分页列表
- function GetPagebreak($totalPage,$nowPage,$aid)
- {
- if($totalPage==1)
- {
- return "";
- }
- //$PageList = "<li><a>共".$totalPage."页: </a></li>";
- $PageList = "<a>共".$totalPage."页: </a>";
- $nPage = $nowPage-1;
- $lPage = $nowPage+1;
- if($nowPage==1)
- {
- //$PageList.="<li><a href='#'>上一页</a></li>";
- $PageList.="<a href='#'>上一页</a>";
- }
- else
- {
- if($nPage==1)
- {
- //$PageList.="<li><a href='".$this->NameFirst.".".$this->ShortName."'>上一页</a></li>";
- $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."'>上一页</a>";
- }
- else
- {
- //$PageList.="<li><a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."'>上一页</a></li>";
- $PageList.="<a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."'>上一页</a>";
- }
- }
- for($i=1;$i<=$totalPage;$i++)
- {
- if($i==1)
- {
- if($nowPage!=1)
- {
- //$PageList.="<li><a href='".$this->NameFirst.".".$this->ShortName."'>1</a></li>";
- $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."'>1</a>";
- }
- else
- {
- //$PageList.="<li class=\"thisclass\"><a href='#'>1</a></li>";
- $PageList.="<a href='#' class='thisclass'>1</a>";
- }
- }
- else
- {
- $n = $i;
- if($nowPage!=$i)
- {
- //$PageList.="<li><a href='".$this->NameFirst."_".$i.".".$this->ShortName."'>".$n."</a></li>";
- $PageList.="<a href='".$this->NameFirst."_".$i.".".$this->ShortName."'>".$n."</a>";
- }
- else
- {
- //$PageList.="<li class=\"thisclass\"><a href='#'>{$n}</a></li>";
- $PageList.="<a href='#' class='thisclass'>{$n}</a>";
- }
- }
- }
- if($lPage <= $totalPage)
- {
- //$PageList.="<li><a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."'>下一页</a></li>";
- $PageList.="<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."'>下一页</a>";
- }
- else
- {
- //$PageList.= "<li><a href='#'>下一页</a></li>";
- $PageList.= "<a href='#'>下一页</a>";
- }
- return $PageList;
- }
二、include/arc.listview.class.php 修改代码如下(注释部分为原有代码,紧跟后面的是修改后的代码)
- //获取静态的分页列表
- function GetPageListST($list_len,$listitem="index,end,pre,next,pageno")
- {
- $prepage = $nextpage = '';
- $prepagenum = $this->PageNo-1;
- $nextpagenum = $this->PageNo+1;
- if($list_len=='' || ereg("[^0-9]",$list_len))
- {
- $list_len=3;
- }
- $totalpage = ceil($this->TotalResult/$this->PageSize);
- if($totalpage<=1 && $this->TotalResult>0)
- {
- //return "<li><span class=\"pageinfo\">共 <strong>1</strong>页<strong>".$this->TotalResult."</strong>条记录</span></li>\r\n";
- return "<a class='current'>共 1 页 ".$this->TotalResult." 条记录</a>";
- }
- if($this->TotalResult == 0)
- {
- //return "<li><span class=\"pageinfo\">共 <strong>0</strong>页<strong>".$this->TotalResult."</strong>条记录</span></li>\r\n";
- return "<a class='current'>共 0 页 ".$this->TotalResult." 条记录</a>";
- }
- $purl = $this->GetCurUrl();
- //$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n";
- $maininfo = "<a class='current'>共 {$totalpage} 页 ".$this->TotalResult." 条</a>";
- $tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
- $tnamerule = ereg_replace('^(.*)/','',$tnamerule);
- //获得上一页和主页的链接
- if($this->PageNo != 1)
- {
- //$prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";
- $prepage.="<a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a>";
- //$indexpage="<li><a href='".str_replace("{page}",1,$tnamerule)."'>首页</a></li>\r\n";
- $indexpage="<a href='".str_replace("{page}",1,$tnamerule)."'>首页</a>";
- }
- else
- {
- //$indexpage="<li>首页</li>\r\n";
- $indexpage="<a class='current'>首页</a>";
- }
- //下一页,未页的链接
- if($this->PageNo!=$totalpage && $totalpage>1)
- {
- //$nextpage.="<li><a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a></li>\r\n";
- $nextpage.="<a href='".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一页</a>";
- //$endpage="<li><a href='".str_replace("{page}",$totalpage,$tnamerule)."'>末页</a></li>\r\n";
- $endpage="<a href='".str_replace("{page}",$totalpage,$tnamerule)."'>末页</a>";
- }
- else
- {
- //$endpage="<li>末页</li>\r\n";
- $endpage="<a class='current'>末页</a>";
- }
- //option链接
- $optionlist = '';
- $optionlen = strlen($totalpage);
- $optionlen = $optionlen*12 + 18;
- if($optionlen < 36) $optionlen = 36;
- if($optionlen > 100) $optionlen = 100;
- //$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
- $optionlist = "<select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>";
- for($mjj=1;$mjj<=$totalpage;$mjj++)
- {
- if($mjj==$this->PageNo)
- {
- $optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."' selected>$mjj</option>\r\n";
- }
- else
- {
- $optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."'>$mjj</option>\r\n";
- }
- }
- //$optionlist .= "</select></li>\r\n";
- $optionlist .= "</select>";
- //获得数字链接
- $listdd="";
- $total_list = $list_len * 2 + 1;
- if($this->PageNo >= $total_list)
- {
- $j = $this->PageNo-$list_len;
- $total_list = $this->PageNo+$list_len;
- if($total_list>$totalpage)
- {
- $total_list=$totalpage;
- }
- }
- else
- {
- $j=1;
- if($total_list>$totalpage)
- {
- $total_list=$totalpage;
- }
- }
- for($j;$j<=$total_list;$j++)
- {
- if($j==$this->PageNo)
- {
- //$listdd.= "<li class=\"current\">$j</li>\r\n";
- $listdd.= "<a class=\"current\">$j</a>";
- }
- else
- {
- //$listdd.="<li><a href='".str_replace("{page}",$j,$tnamerule)."'>".$j."</a></li>\r\n";
- $listdd.="<a href='".str_replace("{page}",$j,$tnamerule)."'>".$j."</a>";
- }
- }
- $plist = '';
- if(eregi('info',$listitem)) $plist .= $maininfo;
- if(eregi('index',$listitem)) $plist .= $indexpage;
- if(eregi('pre',$listitem)) $plist .= $prepage;
- if(eregi('pageno',$listitem)) $plist .= $listdd;
- if(eregi('next',$listitem)) $plist .= $nextpage;
- if(eregi('end',$listitem)) $plist .= $endpage;
- if(eregi('option',$listitem)) $plist .= $optionlist;
- return $plist;
- }
以上代码适用于 dedecms5.6
分页代码调用及样式如下
- <dd class="g_page">
- {dede:pagelist listsize='2' listitem='info,index,end,pre,next,pageno'/}
- </dd>
- .g_page{ width:100%; overflow:hidden; height:22px; text-align:center; margin-top:10px;}
- .g_page a{ display:inline-block; _display:inline; zoom:1; border:1px solid #ccc; height:20px; line-height:20px; padding:0 5px; text-decoration:underline; margin:0 5px 0 0;}
- .g_page .current{ text-decoration:none;}
相关视频
相关阅读 PC6教你如何删除dedecms织梦链dedecms 跨域共享cookie的域名 实际方法dedecms gbk转换UTF-8同版本详细教程dedecms内容模型使用教程DedeCMS没找到正确的uc配置!dedecms5.6 小说频道出错的解决办法dedecms5.6版本的自定义字段的添加和调用方法DedeCMS标签调用详细教程 5.6版
热门文章 Wordpress本地安装教程dx1.5如何设置二级域名
最新文章
hbuilder有哪些快捷键Wordpress本地安装教程
Wordpress本地安装教程expression web 4文档乱码解决方法dz 2.5“收藏本版”关闭小对话框无法关闭解在制作安装软件之前,您必须先将易语言存盘,
人气排行 如何使用multipart/form-data格式上传文件Photoshop PS图层混合模式详解(非常详细)ISAPI_Rewrite3使用教程网站里添加收藏和设为首页代码桌面快捷方式图标不见了C#获取执行程序所在的当前路径的方法详解(XMLHttpRequest)进行跨域请求方法如何用远程桌面连接进行传输文件
查看所有0条评论>>