设为首页 - 加入收藏
广告 1000x90
您的当前位置:主页 > 网站运营 > 正文

织梦模板二次开发文章页实现阅读全文功能的

来源:网络分享 编辑:引流技巧 时间:2026-05-10

现在很多网站尤其是新闻类网站都有阅读全文功能,当一个页面有多个分页的时候就会显示出这个“在本页阅读全文”的链接,点击这个链接之后就是这篇文章以没有分页出现的形式,那么织梦模板如何在文章内容页也实现这个功能呢?


具体实现方法:

首先找到并打开/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、下面的请替换为标准的分页符,,就是去掉空格,因为设置为默认分页符,本文会分页。

01 //阅读全文开始

02 if($this->TotalPage > 1) {

03         //用正则匹配把分页符去掉

04         $this->Fields['body2'] = preg_replace('/#p #副标题 #e#/U', '',$this->Fields['body2']);

05         $this->SplitFields = explode("#p2222#",$this->Fields['body2']);

06         $this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);

07         $this->Fields['title'] = $this->Fields['tmptitle'];

08         $this->TotalPage = count($this->SplitFields);

09         $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>";

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

 

相关推荐:

栏目分类

微商引流技巧网 www.yinliujiqiao.com 联系QQ:1716014443 邮箱:1716014443@qq.com

Copyright © 2019-2024 强大传媒 吉ICP备19000289号-9 网站地图 rss地图

Top