婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 網站建設 > 建站知識 > dedecms5.7文章二次開發實現閱讀全文功能的方法

dedecms5.7文章二次開發實現閱讀全文功能的方法

POST TIME:2021-05-19 22:32

本文實例講述了dedecms5.7文章二次開發實現閱讀全文功能的方法。分享給大家供大家參考。具體分析如下:

閱讀全文功能其實在很多的流行站點都有的,比如網易,新浪等,隨著文章內容的增加,當一個頁面有多個分頁的時候,就會顯示出這個“在本頁閱讀全文”的鏈接,點擊這個鏈接之后出現的,將是這篇文章以沒有分頁出現的型式,那么在dedecms5.7如何在文章內容頁添加閱讀全文功能呢?

這個閱讀全文有什么用呢?說白了,也就是提高用戶體驗,下面讓我們看看,怎么簡單現實這個功能.

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

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

第一步:打開include/arc.archives.class.php

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

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

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

第二步查找:
代碼如下:$this->dsql->ExecuteNoneQuery("Update `dede_archives` SET ismake=1 WHERE id='".$this->ArcID."'");

在上一行添加以下代碼:

代碼如下://閱讀全文開始
if($this->TotalPage > 1) {
//用正則匹配把分頁符去掉
$this->Fields['body2'] = preg_replace('/# p#副標題# e#/U', '',$this->Fields['body2']);
$this->SplitFields = explode("#p2222#",$this->Fields['body2']);
$this->Fields['tmptitle'] = (emptyempty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);
$this->Fields['title'] = $this->Fields['tmptitle'];
$this->TotalPage = count($this->SplitFields);
$this->Fields['totalpage'] = $this->TotalPage;
$TRUEfilenameall = $this->GetTruePath().$fileFirst."_all.".$this->ShortName;
$this->ParseDMFields(1,0);
$this->dtp->SaveTo($TRUEfilenameall);

if($cfg_remote_site=='Y' && $isremote == 1)
{

//分析遠程文件路徑
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
$localfile = '..'.$remotefile;
//創建遠程文件夾
$remotedir = preg_replace("#[^/]*.html#", '', $remotefile);
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
}
//閱讀全文結束
第三步:查找 獲得靜態頁面分頁列表,代碼如下:

代碼如下:/**
* 獲得靜態頁面分頁列表
*
* @access public
* @param int $totalPage 總頁數
* @param int $nowPage 當前頁數
* @param int $aid 文檔id
* @return string
*/
function GetPagebreak($totalPage, $nowPage, $aid)
{
if($totalPage==1)
{
return "";
}
//$PageList = "<li><a>共".$totalPage."頁: </a></li>";
$PageList = "";
$nPage = $nowPage-1;
$lPage = $nowPage+1;
if($nowPage==1)
{
$PageList.="<a href='javascript:void(0);'><</a>";
}
else
{
if($nPage==1)
{
$PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'><</a>";
}
else
{
$PageList.="<a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."' target='_self'><</a>";
}
}
for($i=1;$i<=$totalPage;$i++)
{
if($i==1)
{
if($nowPage!=1)
{
$PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'>1</a>";
}
else
{
$PageList.="<a class="here" href='javascript:void(0);' target='_self'>1</a>";
}
}
else
{
$n = $i;
if($nowPage!=$i)
{
$PageList.="<a href='".$this->NameFirst."_".$i.".".$this->ShortName."' target='_self'>".$n."</a>";
}
else
{
$PageList.="<a class="here" href='javascript:void(0);' target='_self'>{$n}</a>";
}
}
}
if($lPage <= $totalPage)
{
$PageList.="<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."' target='_self'>></a>";
}
else
{
$PageList.= "<a href='javascript:void(0);'>></a>";
}
$PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>";
return $PageList;
}
也就是在return $PageList 上一行添加了一行代碼:

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

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

希望本文所述對大家的dedecms建站有所幫助。




收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 龙井市| 阳江市| 容城县| 苍梧县| 长葛市| 儋州市| 翁牛特旗| 宜昌市| 长白| 黄浦区| 伊川县| 长岭县| 额敏县| 南阳市| 永德县| 时尚| 胶南市| 镇远县| 易门县| 三原县| 漳州市| 布尔津县| 铁力市| 哈巴河县| 视频| 资阳市| 丰县| 沂南县| 新安县| 都江堰市| 绥宁县| 贵溪市| 开化县| 丰都县| 长岛县| 彰化市| 鄄城县| 石台县| 巩义市| 长治县| 凤冈县|