DedeCMS织梦

织梦DedeCMS文章页实现阅读全文功能

阿里云

现在很多网站尤其是新闻类网站都有阅读全文功能,当一个页面有多个分页的时候就会显示出这个“在本页阅读全文”的链接,点击这个链接之后就是这篇文章以没有分页出现的形式,那么 DedeCMS5.7 如何在文章内容页也实现这个功能呢?首先找到并打开/include/arc.archives.class.php 文件,在大概第 145 行左右的位置找到如下代码:

  1. $this->Fields['userip'] = $this->addTableRow['userip'];
也想出现在这里?联系我们
创客主机

在其下面添加如下代码:

  1. $this->Fields['body2'] = $this->addTableRow['body'];

添加完成之后再继续查找如下代码:

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

找到后在其上面添加如下代码:

  1. //阅读全文开始 
  2. if($this->TotalPage > 1) {
  3.         //用正则匹配把分页符去掉
  4.         $this->Fields['body2'] = preg_replace('/#p#副标题#e#/U', '',$this->Fields['body2']);
  5.         $this->SplitFields = explode("#p2222#",$this->Fields['body2']);
  6.         $this->Fields['tmptitle'] = (empty($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.         if($cfg_remote_site=='Y' && $isremote == 1)
  14.         {
  15.         //分析远程文件路径
  16.         $remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
  17.         $localfile = '..'.$remotefile;
  18.         //创建远程文件夹
  19.         $remotedir = preg_replace("#[^\/]*\.HTML#", '', $remotefile);
  20.         $this->ftp->rmkdir($remotedir);
  21.         $this->ftp->upload($localfile, $remotefile, 'ascii');
  22.         }
  23.         } 
  24.  //阅读全文结束

添加完成之后继续在里面查找获得静态页面分页列表的代码,里面有 return $PageList; 在其上面添加如下代码:

  1. $PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>阅读全文</a>";

修改完成后,生成一下内容页就可以看到效果了,当文章内容太多分成多页之后就会在列表后面出现阅读全文的链接了,大家赶快试试吧。

织梦 DedeCMS 文章页实现阅读全文功能

已有 324 人购买
查看演示升级 VIP立刻购买

收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!