phpcms2008添加上一篇下一篇的功能
第一步:修改show.php
在代碼
if(!$C['defaultchargepoint'] && !$r['readpoint'])
前面增加代碼
//
//上一篇文章
$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']='';
}
//
第二步:修改include/html.class.php中的show函數
在代碼
if(strpos($content, '[page]') !== false)
前增加代碼:
//
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']='';
}
//
第三步:在模板目錄/phpcms/show.html檔案中您認為合適的位置添加
- 上一篇: {$more_pre[title]}
- 下一篇: {$more_next[title]}
第四步:在您的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;}