dedecms独立模型分页功能的完善
最后面的共*页*条的信息不见了,相信遇到这个问题的同学首先想到的是自己哪里用错了,其实不是,dede独立模型这里的代码是偷工减料了的。处理独立模型列表的代码在arc.sglistview.class.php中,我们比较下同样负责显示分页的代码段,独立模型和普通模型中有什么区别:
仔细观察 普通模型中在28行左右的位置多了句$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n";而在独立模型中则没有。

/** * 获取动态的分页列表 * * @access public * @param int $list_len 列表宽度 * @param string $listitem 列表样式 * @return string */ function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno") { global $nativeplace,$infotype,$keyword; if(empty($nativeplace)) $nativeplace = 0; if(empty($infotype)) $infotype = 0; if(empty($keyword)) $keyword = ''; $prepage = $nextpage = ''; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; if($list_len=="" || preg_match("/[^0-9]/", $list_len)) { $list_len=3; } $totalpage = ceil($this->TotalResult / $this->PageSize); if($totalpage<=1 && $this->TotalResult>0) { return "<span class=\"pageinfo\">共1页/".$this->TotalResult."条记录</span>"; } if($this->TotalResult == 0) { return "<span class=\"pageinfo\">共0页/".$this->TotalResult."条记录</span>"; } $maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n"; $purl = $this->GetCurUrl(); $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&"; $hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />\r\n"; $hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />\r\n"; $hidenform = "<input type='hidden' name='infotype' value='$infotype' />\r\n"; $hidenform = "<input type='hidden' name='keyword' value='$keyword' />\r\n"; $hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />\r\n"; $purl .= "?".$geturl; //获得上一页和下一页的链接 if($this->PageNo != 1) { $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n"; } else { $indexpage="<li><a>首页</a></li>\r\n"; } if($this->PageNo!=$totalpage && $totalpage>1) { $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; } else { $endpage="<li><a>末页</a></li>"; } //获得数字链接 $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=\"thisclass\"><a>$j</a></li>\r\n"; } else { $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; } } $plist = $indexpage.$prepage.$listdd.$nextpage.$endpage;; return $plist; }
/** * 获取动态的分页列表 * * @access public * @param string $list_len 列表宽度 * @param string $list_len 列表样式 * @return string */ function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno") { global $cfg_rewrite; $prepage = $nextpage = ''; $prepagenum = $this->PageNo-1; $nextpagenum = $this->PageNo+1; if($list_len=='' || preg_match("/[^0-9]/", $list_len)) { $list_len=3; } $totalpage = ceil($this->TotalResult/$this->PageSize); if($totalpage<=1 && $this->TotalResult>0) { return "<li><span class=\"pageinfo\">共 1 页/".$this->TotalResult." 条记录</span></li>\r\n"; } if($this->TotalResult == 0) { return "<li><span class=\"pageinfo\">共 0 页/".$this->TotalResult." 条记录</span></li>\r\n"; } $maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n"; $purl = $this->GetCurUrl(); // 如果开启为静态,则对规则进行替换 if($cfg_rewrite == 'Y') { $nowurls = preg_replace("/\-/", ".php?", $purl); $nowurls = explode("?", $nowurls); $purl = $nowurls[0]; } $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; $purl .= '?'.$geturl; $optionlist = ''; //$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."'>\r\n"; //$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n"; //获得上一页和下一页的链接 if($this->PageNo != 1) { $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n"; } else { $indexpage="<li><a>首页</a></li>\r\n"; } if($this->PageNo!=$totalpage && $totalpage>1) { $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; } else { $endpage="<li><a>末页</a></li>\r\n"; } //获得数字链接 $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=\"thisclass\"><a>$j</a></li>\r\n"; } else { $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; } } $plist = ''; if(preg_match('/index/i', $listitem)) $plist .= $indexpage; if(preg_match('/pre/i', $listitem)) $plist .= $prepage; if(preg_match('/pageno/i', $listitem)) $plist .= $listdd; if(preg_match('/next/i', $listitem)) $plist .= $nextpage; if(preg_match('/end/i', $listitem)) $plist .= $endpage; if(preg_match('/option/i', $listitem)) $plist .= $optionlist; if(preg_match('/info/i', $listitem)) $plist .= $maininfo; if($cfg_rewrite == 'Y') { $plist = str_replace('.php?tid=', '-', $plist); $plist = str_replace('&TotalResult=', '-', $plist); $plist = preg_replace("/&PageNo=(\d+)/i",'-\\1.html',$plist); } return $plist; }
而且在最后,普通模型中将$maininfo的值加入了$plist字符串中。(更细节的地方是普通模型还判断了标签中是否有info属性来决定是否加入:
dede的分页如果有两个页码显示的话,无法显示出总的文章数,举个例子:
dedecms其实在架构方面没什么问题,但是估计里面有些功能是新手做的吧,有很多待完善的地方,比如分页功能,从代码可以直接看出当时的负责人有敷衍了事的心里。
)独立模型中这些都省了。

要将独立模型修改过来很简单,不过“普通模型还判断了标签中是否有info属性来决定是否加入”这点我就不去实现了,这里不判断直接再任何情况下都加入maininfo:
普通文章模型:
独立模型:
但是在独立模型中就成了这样了
在普通文章模型下面,列表的分页是这样的:
相关热词: Dedecms dedecms修改内容 功能 dede 分页
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://www.juheyunku.com/jz/dedecms/3538.shtml
相关文章
热门TAG
命令 权重 外链 企业网站 白帽 php 织梦教程 dedecms修改内容 javascript 织梦 功能 标签 调用 详解 服务器 网站流量 实例解析 Dedecms 织梦cms HTML tags标签 python jquery教程 jquery windows SEO优化 蜘蛛 搜索引擎 网站收录 JSP最新文章
-
织梦友情链接调用和图片
时间:2020-12-29
-
dedecms织梦会员登录二级域
时间:2020-12-29
-
织梦cms手机站首页不更新
时间:2020-12-29
-
织梦DEDECMS提示信息提示框
时间:2020-12-24
-
使用织梦cms做多语言的网
时间:2020-12-24
-
织梦去掉上传图片的水印
时间:2020-12-24
-
DedeCMS Error:Tag disabled:"p
时间:2020-12-24
-
DEDECMS图文分离存放在另一
时间:2020-12-24
热门文章
-
DedeCMS站点高级安全策略(Linux篇)
时间:2020-12-16
-
阿里云主机安装织梦系统出现data无写入权
时间:2020-12-17
-
织梦教程:织梦怎么整合Discuz站点
时间:2020-12-14
-
织梦批量删除文章内容数据库里所有超链
时间:2020-12-17
-
织梦dedecms系统UTF8版编辑器中多图发布按
时间:2020-12-16
-
织梦更换UEditor编辑器后栏目内容、单页无
时间:2020-12-17
-
织梦关键词自动添加链接设置方法
时间:2020-12-15
-
如何防止别人盗用你的织梦模板
时间:2020-12-14
-
织梦dedecms熊掌号时间因子改造教程
时间:2020-12-13
-
DedeCms织梦系统后台把某篇文章设置置顶
时间:2020-12-15
