您现在的位置是:首页 > cms教程 > DedeCMS教程DedeCMS教程

dede织梦文章页面的上一篇下一篇增加文章摘要的方法

陈茗卓2023-12-05DedeCMS教程已有人查阅

导读系统默认的是在dede的上一篇和下一篇的链接只显示标题,但是有时我们希望显示其他信息,比如文章的摘要。

系统默认的是在dede的上一篇和下一篇的链接只显示标题,但是有时我们希望显示其他信息,比如文章的摘要。
找到arc.archives.class.php文件,在include目录下面,然后查找“GetPreNext”这个函数,将
$query
= "Select
arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ";
改成
$query = "Select
arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
arc.description,t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ";
比较一下其实现在只是多了arc.description,这就是文章的摘要,也称为文章描述。需要注意的是这里的jcode_archives和jcode_arctype中的jcode_是我表结构的前缀,你需要将这个前缀改成你自己的。
现在我们已经将文章描述从数据库里面取出来了。下一步将描述显示在页面上,显示连接文字的代码本来是这样的,你可以通过查找找到,其实就在上面那段代码的附近:
if(is_array($preRow))
{
$mlink =
GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],
$preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);
$this->PreNext['pre']
= "上一篇:<a href='$mlink'>{$preRow['title']}</a>
";
$this->PreNext['preimg'] = "<a href='$mlink'><img
src=\"{$preRow['litpic']}\" />";
}
else
{
$this->PreNext['pre'] = "上一篇:没有了 ";
$this->PreNext['preimg']
="<img src=\"/templets/default/images/nophoto.jpg\"
alt=\"对不起,没有上一图集了!\"/>";
}
if(is_array($nextRow))
{
$mlink =
GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],
$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);
$this->PreNext['next']
= "下一篇:<a href='$mlink'>{$nextRow['title']}</a>
";
$this->PreNext['nextimg'] = "<a href='$mlink'><img
src=\"{$nextRow['litpic']}\" />";
}
else
{
$this->PreNext['next'] = "下一篇:没有了 ";
$this->PreNext['nextimg'] ="<a href='javascript:void(0)'
alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\"
alt=\"对不起,没有下一图集了!\"/></a>";
}
}
现在为了显示出文章描述,在每一个a标签之后添加一个div div中包含文章描述(红色部分):
if(is_array($preRow))
{
$mlink =
GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],
$preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);
$this->PreNext['pre']
= "上一篇:<a href='$mlink'>{$preRow['title']}</a> <div>{$preRow['description']}</div>
";
$this->PreNext['preimg'] = "<a href='$mlink'><img
src=\"{$preRow['litpic']}\" />}
else
{
$this->PreNext['pre']
= "上一篇:没有了 ";
$this->PreNext['preimg'] ="<img
src=\"/templets/default/images/nophoto.jpg\"
alt=\"对不起,没有上一图集了!\"/>";
}
if(is_array($nextRow))
{
$mlink =
GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],
$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);
$this->PreNext['next']
= "下一篇:<a href='$mlink'>{$nextRow['title']}</a> <div>{$preRow['description']}</div>
";
$this->PreNext['nextimg'] = "<a href='$mlink'><img
src=\"{$nextRow['litpic']}\" />}
else
{
$this->PreNext['next']
= "下一篇:没有了 ";
$this->PreNext['nextimg'] ="<a href='javascript:void(0)'
alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\"
alt=\"对不起,没有下一图集了!\"/></a>";
}
}

本文标签:

很赞哦! ()

相关源码

  • (PC+WAP)聚氨酯粉末涂料防腐耐用材料粘合剂网站源码下载为化工涂料企业设计的展示系统,集成产品技术参数库、颜色样板展示器和配方查询模块。支持粉末涂料、环氧树脂等多类产品分类展示查看源码
  • 帝国CMS7.5漫画网站模板带手机端源码免费下载本模板为漫画内容平台设计开发,采用帝国CMS7.5内核构建,深度优化漫画作品展示结构与章节管理模式。前端采用响应式布局设计,适配各类漫画阅读场景,提供作品分类、连载追踪、热度排行等垂直领域功能模块。查看源码
  • (PC+WAP)企业管理工程造价资产评估财务审计带留言网站模板本模板基于PbootCMS内核开发,为工程造价咨询、财务审计类企业量身打造,同时支持多行业快速适配。采用PC+WAP双端同步设计,数据实时互通,助您高效展示企业形象与服务能力。查看源码
  • (PC+WAP)红色驾校培训学车在线预约源码下载基于PbootCMS内核开发的驾校培训专用网站模板,深度适配驾驶培训行业展示需求。采用PC与移动端同步响应设计,单一后台统一管理内容数据,更换图文素材后可快速转变为其他行业网站。查看源码
  • (PC+WAP)绿色环保建筑设备通用行业pbootcms源码下载通过模块调整可适配园林景观、装配式建筑、绿色装修等生态建设相关领域。预制绿色建材展示、能耗模拟等专业模块,集成项目案例、环保工艺等建筑行业特色内容结构,测试数据包含LEED认证体系查看源码
  • 帝国CMS游戏应用APP推广下载站模板免费下载本模板为移动应用推广、手机游戏推广行业设计,集成H5游戏平台与APP下载功能,支持PC端与移动端自适应访问。专注于为应用开发商、游戏发行商提供专业的线上推广展示平台。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐