打开模板文件下的news_view.html.php文件,找到(菠萝给起名叫代码一):
<div id=”article_pn”><a href=”{S_URL}/batch.common.php?action=viewnews&op=up&itemid=$news[itemid]&catid=$news[catid]”>上一篇</a> <a href=”{S_URL}/batch.common.php?action=viewnews&op=down&itemid=$news[itemid]&catid=$news[catid]”>下一篇</a></div>
在上面代码前面添加以下代码:
<!–{eval
$query = $_SGLOBAL[‘db’]->query(‘SELECT i.* FROM ‘.tname(‘spaceitems’).’ i WHERE i.itemid>\”.$itemid.’\’ AND catid = \”.$news[‘catid’].’\’ AND type=\”.$news[type].’\’ ORDER BY itemid LIMIT 0,1′);
$newspre = $_SGLOBAL[‘db’]->fetch_array($query);
$query = $_SGLOBAL[‘db’]->query(‘SELECT i.* FROM ‘.tname(‘spaceitems’).’ i WHERE i.itemid<\”.$itemid.’\’ AND catid = \”.$news[‘catid’].’\’ AND type=\”.$news[type].’\’ ORDER BY itemid DESC LIMIT 0,1′);
$newsnext = $_SGLOBAL[‘db’]->fetch_array($query);
$mypre = empty($newspre) ? ‘没有上篇了’ : ‘<a href=”‘.geturl(‘action/viewnews/itemid/’.$newspre[‘itemid’]).'” title=”‘.$newspre[‘subject’].'”>’.$newspre[‘subject’].'</a>’;
$mynext = empty($newsnext) ? ‘没有下篇了’ : ‘<a href=”‘.geturl(‘action/viewnews/itemid/’.$newsnext[‘itemid’]).'” title=”‘.$newsnext[‘subject’].'”>’.$newsnext[‘subject’].'</a>’;
}–>
之后把“代码一”里的代码替换成:
<div id=”article_pn” align=”center”>上篇:$mypre | 下篇:$mynext</div>
OK!你的内容下面就会显示上一篇和下一篇的标题了。这样浏览起来更方便了哦。
评论