phpcms2008添加上一篇下一篇的功能

本文详细介绍了如何在PHPCMS框架中优化文章展示逻辑,通过在关键位置添加代码段,实现上一篇与下一篇文章的自动显示,提升用户体验。同时,通过CSS样式调整,使导航更加美观与易用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


第一步:修改show.php
在代码
if(!$C['defaultchargepoint'] && !$r['readpoint'])
前面增加代码
//<FKE.LA添加代码>
//上一篇文章
$more_pre = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`<$contentid and `catid`='{$r['catid']}' order by contentid desc limit 0,1");
if(empty($more_pre)) {
$more_pre['title']='没有了';
$more_pre['url']='';
}
//下一篇文章
$more_next = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`>$contentid and `catid`='{$r['catid']}' order by contentid asc limit 0,1");
if(empty($more_next)) {
$more_next['title']='没有了';
$more_next['url']='';
}
//</FKE.LA添加代码>

第二步:修改include/html.class.php中的show函数
在代码
if(strpos($content, '[page]') !== false)
前增加代码:
//<FKE.LA添加代码>
global $db;
//上一篇文章
$more_pre = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`<$contentid and `catid`='$catid' order by contentid desc limit 0,1");
if(empty($more_pre)) {
$more_pre['title']='没有了';
$more_pre['url']='';
}
//下一篇文章
$more_next = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`>$contentid and `catid`='$catid' order by contentid asc limit 0,1");
if(empty($more_next)) {
$more_next['title']='没有了';
$more_next['url']='';
}
//</FKE.LA添加代码>

第三步:在模板目录/phpcms/show.html文件中您认为合适的位置添加
<div class="moreArticle"><ul>
<li>上一篇: <a href="{$more_pre[url]}" target="_self">{$more_pre[title]}</a></li>
<li>下一篇: <a href="{$more_next[url]}" target="_self">{$more_next[title]}</a></li>
</ul></div>

第四步:在您的CSS样式文件中添加
/***上一篇下一篇文章链接(fke.la)***/
.moreArticle{
margin:5px 0px;width:100%;
font-size:12px;clear:both;
}
.moreArticle ul{width:100%;}
.moreArticle ul li{width:100%;height:22px;line-height:22px;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值