公司运营的一个网站重构,后台采用dedecms5.6,我主要负责前端。
个人觉得,dede默认的分页功能比较丑、不够简洁,并且很不好用,用户体验那个叫差;并且于SEO来说,dede默认分页的链接方式不是很合理。
个人比较喜欢腾讯,时光网,京东等门户网站的分页风格。
老大和我都比较要求网站的细节,于是开始动手写代码,发现dede分页标签默认调出的内容含有,并且没有赋值标示上一页,下一页等基本元素。
为了实现门户网站分页风格,需要改dede分页标签的编译文件了。
已经习惯了搜索引擎的我,肯定是先在百度找,找了半天,没找到相关教程。
只好自己动手改。
下载地址
不啰嗦了,下面是修改步骤:
1.找到根目录下的“include”文件夹下的“arc.listview.class.php”文件,打开。 网站根目录/include/arc.listview.class.php
2.ctrl+f找到“//获取静态的分页列表”。 把“//获取静态的分页列表”到“//获取动态的分页列表”之间的代码(GetPageListST函数)修改为以下:
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=2; } $totalpage = ceil($this->TotalResult/$this->PageSize); if($totalpage<=1 && $this->TotalResult>0) {
return "; } if($this->TotalResult == 0) { return "; } $purl = $this->GetCurUrl(); $maininfo = "; $tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']); $tnamerule = ereg_replace('^(.*)/','',$tnamerule); //分页第一页链接 12.15 李楠修改 $typedir= ereg_replace('{cmspath}',$GLOBALS['cfg_cmspath'],$this->Fields['typedir']); //变量:默认文档名称,比如index.html $defaultname= ereg_replace('{cmspath}',$GLOBALS['cfg_cmspath'],$this->Fields['defaultname']); //获得上一页和主页的链接 if($this->PageNo != 1) { if($this->PageNo == 2) { $prepage.="<a href=\"".$typedir."/\" class=\"pageNum prepage\">上一页"; } else { $prepage.="<a href='".str_replace("{page}",$prepagenum,$tnamerule)."' class=\"pageNum prepage\">上一页"; } if($totalpage <= 10) { $indexpage="<A class=\ href="http://edit.jfsky.com/" pageNum\?? ?.$typedir.? _xhe_href="\" \??>1"; } else { if($this->PageNo < $list_len*2+1) { $indexpage="<A class=\ href="http://edit.jfsky.com/" pageNum\?? ?.$typedir.? _xhe_href="\" \??>1"; } else { $indexpage="<A class=\ href="http://edit.jfsky.com/" pageNum\?? ?.$typedir.? _xhe_href="\" \??>1<SPAN class=\ pageBreak\??>…"; &nbs