dedecms其实在架构方面没什么问题,但是估计里面有些功能是新手做的吧,有很多待完善的地方,比如分页功能,从代码可以直接看出当时的负责人有敷衍了事的心里。
dede的分页如果有两个页码显示的话,无法显示出总的文章数,举个例子:
在普通文章模型下面,列表的分页是这样的:

但是在独立模型中就成了这样了

最后面的共*页*条的信息不见了,相信遇到这个问题的同学首先想到的是自己哪里用错了,其实不是,dede独立模型这里的代码是偷工减料了的。处理独立模型列表的代码在arc.sglistview.class.php中,我们比较下同样负责显示分页的代码段,独立模型和普通模型中有什么区别:
普通文章模型:
005 | * @param string $list_len 列表宽度 |
006 | * @param string $list_len 列表样式 |
009 | functionGetPageListDM($list_len,$listitem="index,end,pre,next,pageno") |
012 | $prepage = $nextpage = ''; |
013 | $prepagenum = $this->PageNo-1; |
014 | $nextpagenum = $this->PageNo+1; |
015 | if($list_len==''|| preg_match("/[^0-9]/", $list_len)) |
019 | $totalpage = ceil($this->TotalResult/$this->PageSize); |
020 | if($totalpage<=1 && $this->TotalResult>0) |
022 | return"<li><span class=\"pageinfo\">共 1 页/".$this->TotalResult." 条记录</span></li>\r\n"; |
024 | if($this->TotalResult == 0) |
026 | return"<li><span class=\"pageinfo\">共 0 页/".$this->TotalResult." 条记录</span></li>\r\n"; |
028 | $maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n"; |
029 | $purl = $this->GetCurUrl(); |
031 | if($cfg_rewrite == 'Y') |
033 | $nowurls = preg_replace("/\-/", ".php?", $purl); |
034 | $nowurls = explode("?", $nowurls); |
037 | $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; |
040 | //$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."'>\r\n"; |
041 | //$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n"; |
043 | if($this->PageNo != 1) |
045 | $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; |
046 | $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n"; |
050 | $indexpage="<li><a>首页</a></li>\r\n"; |
052 | if($this->PageNo!=$totalpage && $totalpage>1) |
054 | $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; |
055 | $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; |
059 | $endpage="<li><a>末页</a></li>\r\n"; |
063 | $total_list = $list_len * 2 + 1; |
064 | if($this->PageNo >= $total_list) |
066 | $j = $this->PageNo-$list_len; |
067 | $total_list = $this->PageNo+$list_len; |
068 | if($total_list>$totalpage) |
070 | $total_list=$totalpage; |
076 | if($total_list>$totalpage) |
078 | $total_list=$totalpage; |
081 | for($j;$j<=$total_list;$j++) |
085 | $listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n"; |
089 | $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; |
093 | if(preg_match('/index/i', $listitem)) $plist .= $indexpage; |
094 | if(preg_match('/pre/i', $listitem)) $plist .= $prepage; |
095 | if(preg_match('/pageno/i', $listitem)) $plist .= $listdd; |
096 | if(preg_match('/next/i', $listitem)) $plist .= $nextpage; |
097 | if(preg_match('/end/i', $listitem)) $plist .= $endpage; |
098 | if(preg_match('/option/i', $listitem)) $plist .= $optionlist; |
099 | if(preg_match('/info/i', $listitem)) $plist .= $maininfo; |
100 | if($cfg_rewrite == 'Y') |
102 | $plist = str_replace('.php?tid=', '-', $plist); |
103 | $plist = str_replace('&TotalResult=', '-', $plist); |
104 | $plist = preg_replace("/&PageNo=(\d+)/i",'-\\1.html',$plist); |
|
独立模型:
05 | * @param int $list_len 列表宽度 |
06 | * @param string $listitem 列表样式 |
09 | functionGetPageListDM($list_len,$listitem="index,end,pre,next,pageno") |
11 | global $nativeplace,$infotype,$keyword; |
12 | if(empty($nativeplace)) $nativeplace = 0; |
13 | if(empty($infotype)) $infotype = 0; |
14 | if(empty($keyword)) $keyword = ''; |
15 | $prepage = $nextpage = ''; |
16 | $prepagenum = $this->PageNo - 1; |
17 | $nextpagenum = $this->PageNo + 1; |
18 | if($list_len==""|| preg_match("/[^0-9]/", $list_len)) |
22 | $totalpage = ceil($this->TotalResult / $this->PageSize); |
23 | if($totalpage<=1 && $this->TotalResult>0) |
25 | return"<span class=\"pageinfo\">共1页/".$this->TotalResult."条记录</span>"; |
27 | if($this->TotalResult == 0) |
29 | return"<span class=\"pageinfo\">共0页/".$this->TotalResult."条记录</span>"; |
31 | $purl = $this->GetCurUrl(); |
32 | $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&"; |
33 | $hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />\r\n"; |
34 | $hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />\r\n"; |
35 | $hidenform = "<input type='hidden' name='infotype' value='$infotype' />\r\n"; |
36 | $hidenform = "<input type='hidden' name='keyword' value='$keyword' />\r\n"; |
37 | $hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />\r\n"; |
42 | $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; |
43 | $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n"; |
47 | $indexpage="<li><a>首页</a></li>\r\n"; |
49 | if($this->PageNo!=$totalpage && $totalpage>1) |
51 | $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; |
52 | $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; |
56 | $endpage="<li><a>末页</a></li>"; |
60 | $total_list = $list_len * 2 + 1; |
61 | if($this->PageNo >= $total_list) |
63 | $j = $this->PageNo - $list_len; |
64 | $total_list = $this->PageNo + $list_len; |
65 | if($total_list > $totalpage) |
67 | $total_list = $totalpage; |
73 | if($total_list > $totalpage) |
75 | $total_list = $totalpage; |
78 | for($j; $j <= $total_list; $j++) |
80 | if($j == $this->PageNo) |
82 | $listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n"; |
86 | $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; |
89 | $plist = $indexpage.$prepage.$listdd.$nextpage.$endpage; |
|
仔细观察 普通模型中在28行左右的位置多了句$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n";而在独立模型中则没有。
而且在最后,普通模型中将$maininfo的值加入了$plist字符串中。(更细节的地方是普通模型还判断了标签中是否有info属性来决定是否加入:
1 | if(preg_match('/info/i', $listitem)) $plist .= $maininfo; |
|
)独立模型中这些都省了。
要将独立模型修改过来很简单,不过“普通模型还判断了标签中是否有info属性来决定是否加入”这点我就不去实现了,这里不判断直接再任何情况下都加入maininfo:
05 | * @param int $list_len 列表宽度 |
06 | * @param string $listitem 列表样式 |
09 | functionGetPageListDM($list_len,$listitem="index,end,pre,next,pageno") |
11 | global $nativeplace,$infotype,$keyword; |
12 | if(empty($nativeplace)) $nativeplace = 0; |
13 | if(empty($infotype)) $infotype = 0; |
14 | if(empty($keyword)) $keyword = ''; |
15 | $prepage = $nextpage = ''; |
16 | $prepagenum = $this->PageNo - 1; |
17 | $nextpagenum = $this->PageNo + 1; |
18 | if($list_len==""|| preg_match("/[^0-9]/", $list_len)) |
22 | $totalpage = ceil($this->TotalResult / $this->PageSize); |
23 | if($totalpage<=1 && $this->TotalResult>0) |
25 | return"<span class=\"pageinfo\">共1页/".$this->TotalResult."条记录</span>"; |
27 | if($this->TotalResult == 0) |
29 | return"<span class=\"pageinfo\">共0页/".$this->TotalResult."条记录</span>"; |
31 | $maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>\r\n"; |
32 | $purl = $this->GetCurUrl(); |
33 | $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&"; |
34 | $hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />\r\n"; |
35 | $hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />\r\n"; |
36 | $hidenform = "<input type='hidden' name='infotype' value='$infotype' />\r\n"; |
37 | $hidenform = "<input type='hidden' name='keyword' value='$keyword' />\r\n"; |
38 | $hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />\r\n"; |
43 | $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n"; |
44 | $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n"; |
48 | $indexpage="<li><a>首页</a></li>\r\n"; |
50 | if($this->PageNo!=$totalpage && $totalpage>1) |
52 | $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n"; |
53 | $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n"; |
57 | $endpage="<li><a>末页</a></li>"; |
61 | $total_list = $list_len * 2 + 1; |
62 | if($this->PageNo >= $total_list) |
64 | $j = $this->PageNo - $list_len; |
65 | $total_list = $this->PageNo + $list_len; |
66 | if($total_list > $totalpage) |
68 | $total_list = $totalpage; |
74 | if($total_list > $totalpage) |
76 | $total_list = $totalpage; |
79 | for($j; $j <= $total_list; $j++) |
81 | if($j == $this->PageNo) |
83 | $listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n"; |
87 | $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n"; |
90 | $plist = $indexpage.$prepage.$listdd.$nextpage.$endpage;; |
|
郑重声明:
本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。
若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。
我们不承担任何技术及版权问题,且不对任何资源负法律责任。
如无法下载,联系站长索要。
如有侵犯您的版权,请给我们来信:cainiaovip8@qq.com,我们尽快处理。