• <ul id="cgeq2"></ul>
  • 歡迎您光臨深圳塔燈網(wǎng)絡科技有限公司!
    電話圖標 余先生:13699882642

    dedecms獨立模型分頁功能的完善

    發(fā)表日期:2017-11 文章編輯:小燈 瀏覽次數(shù):3272

    dedecms其實在架構方面沒什么問題,但是估計里面有些功能是新手做的吧,有很多待完善的地方,比如分頁功能,從代碼可以直接看出當時的負責人有敷衍了事的心里。

    dede的分頁如果有兩個頁碼顯示的話,無法顯示出總的文章數(shù),舉個例子:

    在普通文章模型下面,列表的分頁是這樣的:

    但是在獨立模型中就成了這樣了

    最后面的共*頁*條的信息不見了,相信遇到這個問題的同學首先想到的是自己哪里用錯了,其實不是,dede獨立模型這里的代碼是偷工減料了的。處理獨立模型列表的代碼在arc.sglistview.class.php中,我們比較下同樣負責顯示分頁的代碼段,獨立模型和普通模型中有什么區(qū)別:

    普通文章模型:

    /*** 獲取動態(tài)的分頁列表** @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();// 如果開啟為靜態(tài),則對規(guī)則進行替換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";}//獲得數(shù)字鏈接$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;}

    獨立模型:

    /*** 獲取動態(tài)的分頁列表** @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>";}$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>";}//獲得數(shù)字鏈接$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;}

    仔細觀察 普通模型中在28行左右的位置多了句$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>頁<strong>".$this->TotalResult."</strong>條</span></li>\r\n";而在獨立模型中則沒有。

    而且在最后,普通模型中將$maininfo的值加入了$plist字符串中。(更細節(jié)的地方是普通模型還判斷了標簽中是否有info屬性來決定是否加入:

    if(preg_match('/info/i', $listitem)) $plist .= $maininfo;

    )獨立模型中這些都省了。

    要將獨立模型修改過來很簡單,不過“普通模型還判斷了標簽中是否有info屬性來決定是否加入”這點我就不去實現(xiàn)了,這里不判斷直接再任何情況下都加入maininfo:

    /*** 獲取動態(tài)的分頁列表** @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>";}//獲得數(shù)字鏈接$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;}


    本頁內容由塔燈網(wǎng)絡科技有限公司通過網(wǎng)絡收集編輯所得,所有資料僅供用戶參考了本站不擁有所有權,如您認為本網(wǎng)頁中由涉嫌抄襲的內容,請及時與我們聯(lián)系,并提供相關證據(jù),工作人員會在5工作日內聯(lián)系您,一經查實,本站立刻刪除侵權內容。本文鏈接:http://www.juherenli.com/11248.html
    相關cms文章
     八年  行業(yè)經驗

    多一份參考,總有益處

    聯(lián)系深圳網(wǎng)站公司塔燈網(wǎng)絡,免費獲得網(wǎng)站建設方案及報價

    咨詢相關問題或預約面談,可以通過以下方式與我們聯(lián)系

    業(yè)務熱線:余經理:13699882642

    Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.    

    国产亚洲精品美女久久久久| 久久久久无码国产精品一区| 2021国产精品视频| 中文字幕久精品免费视频| 欧美黑人巨大精品videos| 久久久久久国产精品视频 | 91精品成人免费国产片| 精品无码三级在线观看视频| 精品久久久久国产免费 | 狠狠久久精品中文字幕无码| 久久久久无码精品国产不卡| 国产亚洲精品AA片在线观看不加载| 亚洲av无码成人精品国产| 亚洲国产精品人久久| 久久国产精品波多野结衣AV| 国产精品自在自线免费观看| 亚洲精品成人久久| 久久精品无码精品免费专区| 精品国产一区二区三区在线观看| 国产视频精品久久| 青青草原综合久久大伊人精品 | 亚洲日韩精品无码专区网站| 国产99视频精品专区| 国产成人精品男人的天堂538| 久久精品国产2020观看福利| H无码精品3D动漫在线观看| 精品91一区二区三区| 欧洲精品无码成人久久久 | 国产亚洲精品无码成人| 精品国产不卡一区二区三区| 国产成人精品影院狼色在线 | 老司机性色福利精品视频| 亚洲中文久久精品无码| 精品精品国产国产| 老司机免费午夜精品视频 | 成人综合婷婷国产精品久久蜜臀| 2021精品国产综合久久| 国产精品美女久久久久网| 91精品国产乱码在线观看| 久久精品国产福利电影网| 国产麻豆一精品一AV一免费|