国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > CMS > 織夢(mèng)DEDE > 正文

dedecms5.7文章實(shí)現(xiàn)閱讀全文功能二次開(kāi)發(fā)

2024-07-12 08:43:33
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

現(xiàn)在很多網(wǎng)站支持當(dāng)前文章分頁(yè)的同時(shí)還可以有一個(gè)閱讀全文按鈕了,像網(wǎng)易新聞就有這個(gè)功能了,那么對(duì)于dedecms不具備此功能了,下面我們就來(lái)幫它改改吧。

閱讀全文功能其實(shí)在很多的流行站點(diǎn)都有的,比如網(wǎng)易,新浪等,隨著文章內(nèi)容的增加,當(dāng)一個(gè)頁(yè)面有多個(gè)分頁(yè)的時(shí)候,就會(huì)顯示出這個(gè)“在本頁(yè)閱讀全文”的鏈接,點(diǎn)擊這個(gè)鏈接之后,出現(xiàn)的,將是這篇文章以沒(méi)有分頁(yè)出現(xiàn)的型式。,那么在dedecms5.7如何在文章內(nèi)容頁(yè)添加閱讀全文功能呢?

dedecms5.7文章實(shí)現(xiàn)閱讀全文功能二次開(kāi)發(fā)

這個(gè)閱讀全文有什么用呢?說(shuō)白了,也就是提高用戶體驗(yàn)。下面讓我們看看,怎么簡(jiǎn)單現(xiàn)實(shí)這個(gè)功能。

修改文件:include/arc.archives.class.php

注意:做任何修改前都要備份好原文件。

第一步:打開(kāi)include/arc.archives.class.php

文件查找://issystem==-1

往下 大概 145行 找到 $this->Fields['userip'] = $this->addTableRow['userip'];

在下面一行添加:$this->Fields['body2'] = $this->addTableRow['body'];

第二步:查找:$this->dsql->ExecuteNoneQuery("Update `#@__archives` SET ismake=1 WHERE id='".$this->ArcID."'");

在上一行添加以下代碼:

  1. //閱讀全文開(kāi)始 
  2. if($this->TotalPage > 1) { 
  3.         //用正則匹配把分頁(yè)符去掉 
  4.  $this->Fields['body2'] = preg_replace('/#p#副標(biāo)題#e#/U''',$this->Fields['body2']); 
  5.  $this->SplitFields = explode("#p2222#",$this->Fields['body2']); 
  6.  $this->Fields['tmptitle'] = (emptyempty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']); 
  7.  $this->Fields['title'] = $this->Fields['tmptitle']; 
  8.  $this->TotalPage = count($this->SplitFields); 
  9.  $this->Fields['totalpage'] = $this->TotalPage; 
  10.  $TRUEfilenameall = $this->GetTruePath().$fileFirst."_all.".$this->ShortName; 
  11.  $this->ParseDMFields(1,0); 
  12.  $this->dtp->SaveTo($TRUEfilenameall); 
  13.         
  14.  if($cfg_remote_site=='Y' && $isremote == 1) 
  15.  { 
  16.         
  17.   //分析遠(yuǎn)程文件路徑 
  18.   $remotefile = str_replace(DEDEROOT, ''$TRUEfilename); 
  19.   $localfile = '..'.$remotefile
  20.   //創(chuàng)建遠(yuǎn)程文件夾 
  21.   $remotedir = preg_replace("#[^\/]*\.html#"''$remotefile); 
  22.   $this->ftp->rmkdir($remotedir); 
  23.   $this->ftp->upload($localfile$remotefile'ascii'); 
  24.  } 
  25. //閱讀全文結(jié)束 

第三步:查找 獲得靜態(tài)頁(yè)面分頁(yè)列表,代碼如下:

  1. /** 
  2.  *  獲得靜態(tài)頁(yè)面分頁(yè)列表 
  3.  * 
  4.  * @access    public 
  5.  * @param     int   $totalPage  總頁(yè)數(shù) 
  6.  * @param     int   $nowPage  當(dāng)前頁(yè)數(shù) 
  7.  * @param     int   $aid  文檔id 
  8.  * @return    string 
  9.  */ 
  10.   function GetPagebreak($totalPage$nowPage$aid
  11.     if($totalPage==1) 
  12.     { 
  13.         return ""
  14.     } 
  15.     //$PageList = "<li><a>共".$totalPage."頁(yè): </a></li>"; 
  16.     $PageList = ""
  17.     $nPage = $nowPage-1; 
  18.     $lPage = $nowPage+1; 
  19.     if($nowPage==1) 
  20.     { 
  21.         $PageList.="<a href='javascript:void(0);'><</a>"
  22.     } 
  23.     else 
  24.     { 
  25.         if($nPage==1) 
  26.         { 
  27.             $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'><</a>"
  28.         } 
  29.         else 
  30.         { 
  31.             $PageList.="<a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."' target='_self'><</a>"
  32.         } 
  33.     } 
  34.     for($i=1;$i<=$totalPage;$i++) 
  35.     { 
  36.         if($i==1) 
  37.         { 
  38.             if($nowPage!=1) 
  39.             { 
  40.                 $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'>1</a>"
  41.             } 
  42.             else 
  43.             { 
  44.                 $PageList.="<a class=\"here\" href='javascript:void(0);' target='_self'>1</a>"
  45.             } 
  46.         } 
  47.         else 
  48.         { 
  49.             $n = $i
  50.             if($nowPage!=$i
  51.             { 
  52.                 $PageList.="<a href='".$this->NameFirst."_".$i.".".$this->ShortName."' target='_self'>".$n."</a>"
  53.             } 
  54.             else 
  55.             { 
  56.                 $PageList.="<a class=\"here\" href='javascript:void(0);' target='_self'>{$n}</a>"
  57.             } 
  58.         } 
  59.     } 
  60.     if($lPage <= $totalPage
  61.     { 
  62.         $PageList.="<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."' target='_self'>></a>"
  63.     } //Vevb.com 
  64.     else 
  65.     { 
  66.         $PageList.= "<a href='javascript:void(0);'>></a>"
  67.     } 
  68.        $PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>"
  69.     return $PageList

也就是在return $PageList 上一行添加了一行代碼:

$PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>";

修改完成后,保存文件,更新一下頁(yè)面就可以看到效果了.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 建瓯市| 仲巴县| 新乡市| 宜君县| 鞍山市| 咸丰县| 博客| 新宾| 南陵县| 翼城县| 北碚区| 顺平县| 阳新县| 抚宁县| 永康市| 都兰县| 安吉县| 南丹县| 留坝县| 凤翔县| 乡城县| 威远县| 吴川市| 鹤峰县| 双辽市| 垣曲县| 海口市| 东平县| 新巴尔虎左旗| 胶州市| 马边| 赤壁市| 沭阳县| 华池县| 新化县| 子长县| 沂水县| 鹿泉市| 连山| 乐至县| 始兴县|