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

dedecms织梦上一篇下一篇怎么增加文章描述

陶旭笙2023-10-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 `xxy5.com_archives` arc left join xxy5.com_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 `xxy5.com_archives` arc left join xxy5.com_arctype t on arc.typeid=t.id “;
比较一下其实现在只是多了arc.description,这就是文章的摘要,也称为文章描述。
需要注意的是这里的xxy5.com_archives和xxy5.com_arctype中的xxy5.com_是表结构的前缀,你需要将这个前缀改成你自己的。
现在我们已经将文章描述从数据库里面取出来了。下一步将描述显示在页面上,显示连接文字的代码本来是这样的,你可以通过查找找到,其实就在上面那段代码的附近:
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']}” alt=”{$preRow['title']}”/></a>
“;
}
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']}” alt=”{$nextRow['title']}”/></a>
“;
}
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']}” alt=”{$preRow['title']}”/></a> <div>{$preRow['description']}</div> “;
}
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']}” alt=”{$nextRow['title']}”/></a> <div>{$preRow['description']}</div> “;
}
else
{
$this->PreNext['next']
= “下一篇:没有了 “;
$this->PreNext['nextimg'] =”<a href=’javascript:void(0)’
alt=”"><img src=”/templets/default/images/nophoto.jpg”
alt=”对不起,没有下一图集了!”/></a>”;
}
}
这样做的话能显示文章摘要,但是格式可能会很乱,你可以根据需要增加样式。

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)HTML5电脑手机电子数码产品配件pbootcms模板下载本模板为电脑配件、手机配件及数码周边产品企业设计,基于PbootCMS内核开发。采用现代化响应式布局,适配各类移动设备,能够专业展示各类电子产品配件参数、应用场景和技术特点。模板内置多种产品展示模块,满足不同类型配件企业的展示需求。查看源码
  • 帝国cms7.5自适应手机端在线课程教育网站源码基于帝国CMS后台管理系统,支持在线修改支付参数、联系方式等配置信息,操作界面直观便捷。专注于在线教育视频领域,提供完整的视频课程展示、付费购买及在线支付解决方案。支持多种支付渠道,满足教育培训机构的运营需求。查看源码
  • (自适应)行业协会工会机构单位pbootcms网站源码本模板基于PbootCMS内核开发,为行业协会、工会组织及机构单位量身打造。采用响应式布局设计,可自动适配手机、平板等移动设备,数据实时同步更新。模板包含行业资讯查看源码
  • (PC模板)工商公司注册会计财务记账pbootcms模板源码下载基于PbootCMS的工商财税行业网站系统,手工编写前端代码确保执行效率,双端自适应设计,支持后台实时更新服务价格和政策文件。查看源码
  • (PC+WAP)货运物流快递仓储货架pbootcms网站模板下载本模板基于PbootCMS开发,为货运物流、快递配送、仓储货架等行业设计,支持PC+WAP自适应,确保在电脑、手机、平板等设备上均能流畅访问。适用于物流公司、仓储企业查看源码
  • (自适应)宽屏农业机械农耕设备类网站pbootcms模板免费下载为农机企业打造的现代化响应式网站模板,自动适配电脑、平板和手机,浏览体验一致,独立页面SEO设置,提升搜索引擎可见度。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐