dedecms5.7文章二次开发实现阅读全文功能的方法

Dedecms5.7文章二次开发实现阅读全文功能方法分享给大家供大家参考。具体分析如下:

功能其实在很多的流行站点都有的,比如网易,新浪等,随着文章内容增加,当一个页面有多个分页的时候,就会显示出这个“在本页阅读全文”的链接,点击这个链接之后出现的,将是这篇文章以没有分页出现的型式,那么在Dedecms5.7如何在文章内容添加阅读全文功能呢?

用户体验,下面让我们看看,怎么简单现实这个功能.

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

修改前都要备份好原文件.

PHP

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

复制代码
代码如下:
Fields['userip'] = $this->addTableRow['userip'];

添加:

复制代码
代码如下:
Fields['body2'] = $this->addTableRow['body'];

复制代码
代码如下:
dsql->ExecuteNoneQuery("Update `dede_archives` SET ismake=1 WHERE id='".$this->ArcID."'");

添加以下代码:

复制代码
代码如下:
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'); } } //阅读全文结束

页面分页列表,代码如下:

复制代码
代码如下:
PHP">/** * 获得静态页面分页列表 * * @access public * @param int $totalPage 总页数 * @param int $NowPage 当前页数 * @param int $aid 文档id * @return string */ function GetPagebreak($totalPage,$NowPage,$aid) { if($totalPage==1) { return ""; } //$Pagelist = " 共".$totalPage."页: "; $Pagelist = ""; $nPage = $NowPage-1; $lPage = $NowPage+1; if($NowPage==1) { $Pagelist.="<"; } else { if($nPage==1) { $PageList.="NameFirst.".".$this->ShortName."' target='_self'><"; } else { $PageList.="NameFirst."_".$nPage.".".$this->ShortName."' target='_self'><"; } } for($i=1;$i<=$totalPage;$i++) { if($i==1) { if($nowPage!=1) { $PageList.="NameFirst.".".$this->ShortName."' target='_self'>1"; } else { $Pagelist.="1"; } } else { $n = $i; if($NowPage!=$i) { $Pagelist.="NameFirst."_".$i.".".$this->ShortName."' target='_self'>".$n.""; } else { $Pagelist.="{$n}"; } } } if($lPage <= $totalPage) { $PageList.="NameFirst."_".$lPage.".".$this->ShortName."' target='_self'>>"; } else { $Pagelist.= ">"; } $Pagelist.= "NameFirst."_all.".$this->ShortName."'>阅读全文"; return $Pagelist; }

Pagelist 上一行添加了一行代码:

复制代码
代码如下:
ShortName."'>阅读全文";

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

Dedecms建站有所帮助。

阅读全文

相关文章

本教程操作系统:Windows10系统、DedeCMS 5.7.109版本、Dell...
在Dedecms织梦列表页中是肯定要使用pagelist标签的,但是有的...
今天分享织梦网站怎么搬家,个人感觉织梦的搬家比其他的程序...
织梦(dede)程序不安全是公认的,同样是建站,使用织梦程序...
使用xemu、爱站工具包、尖叫青蛙等制作网站地图,每次生成si...
分享织梦自动生成网站sitemap,但是需要安装插件,今天分享,...