足球游戏_中国足彩网¥体育资讯$

dedecms5.7文章二次开发实现阅读全文功能的方法
来源:易贤网 阅读:562 次 日期:2015-03-04 11:36:11
温馨提示:易贤网小编为您整理了“dedecms5.7文章二次开发实现阅读全文功能的方法”,方便广大网友查阅!

本文实例讲述了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建站有所帮助。

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看CMS教程
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标