admin 2007-12-13 18:03
简单修改,成功调出上一篇、下一篇资讯标题
功能不再介绍,看截图演示:
[url=http://www.discuz.net/thread-796020-1-3.html###zoom][img]http://www.discuz.net/attachments/month_0711/20071127_0b00e2aa4b27927a5ba8gaDe2nQzZ8WX.jpg.thumb.jpg[/img][/url]
修改方法,以默认模板为例:
1)打开 news_view.html.php 找到下面的代码
[free]
<div id="articledetail" class="block topblock">
<h3 style="font-weight: normal;">
<a href="javascript:;" class="more">推荐给好友</a>
<a href="{S_URL}/batch.common.php?action=viewnews&op=up&itemid=$news[itemid]&catid=$news[catid]" class="viewnewsup">上一篇</a> |
<a href="{S_URL}/batch.common.php?action=viewnews&op=down&itemid=$news[itemid]&catid=$news[catid]" class="viewnewsdown">下一篇</a>
</h3>
<h1 class="articletitle" style="$news[styletitle]">$news[subject]</h1>
<p class="articleinfo">
<span class="articlectrl">
字体:
<a href="javascript:doZoom('12');">小</a>
<a href="javascript:doZoom('14');">中</a>
<a href="javascript:doZoom('16');">大</a> |
<a href="javascript:doPrint();" class="btnprint">打印</a>
</span>
<span class="smalltxt">发布: #date('Y-n-d H:i', $news["dateline"])# 作者: $news[newsauthor] 来源: <!--{if !empty($news[newsfromurl])}--><a href="$news[newsfromurl]" target="_blank" title="$news[newsfrom]">$news[newsfrom]</a><!--{else}-->$news[newsfrom]<!--{/if}--> 查看: $news[viewnum]次</span>
</p>
<!--{if !empty($news[custom][name])}-->
<br />
<div id="custominfo">
<h5>$news[custom][name]</h5>
<ul>
<!--{loop $news[custom][key] $ckey $cvalue}-->
<li><strong>$cvalue[name]: </strong>$news[custom][value][$ckey]</li>
<!--{/loop}-->
</ul>
</div>
<!--{/if}-->
<div id="articlebody">
$news[message]
<!--{if empty($multipage)}-->
<!--{loop $news['attacharr'] $attach}-->
<br /><a href="$attach[url]" target="_blank"><img src="$attach[thumbpath]" alt="$attach[subject]" /></a><br />$attach[subject]<br />
<!--{/loop}-->
<!--{/if}-->
<br />
<!--{if !empty($relativetagarr)}-->
<br /><strong>TAG:</strong>
<!--{loop $relativetagarr $value}-->
<!--{eval $svalue = rawurlencode($value);}-->
<a href="#action/tag/tagname/$svalue#" target="_blank">$value</a>
<!--{/loop}-->
<!--{/if}-->
</div>
<!--{if $multipage}-->
<div class="pages">
$multipage
</div>
<!--{/if}-->
</div>
[/free]
在最后的这个</div>上面添加以下代码:
[free] <ul class="msgtitlelist">
<li>上一篇:<a href="{S_URL}/batch.common.php?action=viewnews&op=up&itemid=$news[itemid]&catid=$news[catid]" class="viewnewsup">$title_a</a></li>
<li>下一篇:<a href="{S_URL}/batch.common.php?action=viewnews&op=down&itemid=$news[itemid]&catid=$news[catid]" class="viewnewsdown">$title_b</a></li>
</ul>
[/free]
布局可根据自己的情况修改,链接代码不要改。
2)打开SS安装目录下的 viewnews.php 文件,在最下部找到:
[free] include template($tplname);
ob_out();
if(!empty($_SCONFIG['htmlviewnews'])) {
ehtml('make');
} else {
maketplblockvalue('cache');
}
?>
[/free]
在这段代码上面添加以下代码:
[free] //调用上一篇资讯标题
$title_a = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT subject FROM '.tname('spaceitems').' WHERE itemid < \''.$itemid.'\' AND catid = \''.$thecat['catid'].'\' AND folder=\'1\' AND type=\'news\' ORDER BY itemid DESC LIMIT 0,1'), 0);
if(!$title_a) $title_a = '已经没有了';
//调用下一篇资讯标题
$title_b = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT subject FROM '.tname('spaceitems').' WHERE itemid > \''.$itemid.'\' AND catid = \''.$thecat['catid'].'\' AND folder=\'1\' AND type=\'news\' ORDER BY itemid LIMIT 0,1'), 0);
if(!$title_b) $title_b = '已经没有了';
//代码结束
[/free]
本人表达能力不行,如有疏漏再所难免,还请大家多多支持
loveshu1216 2008-9-29 12:10
楼主,你写得实在是太好了。我惟一能做的,就只有把这个帖子顶上去这件事了
xunleifilm 2008-10-1 11:10
这些我好像在QQ群里经常看到
jsjsj的弟弟 2008-10-22 15:10
经过你的指点 我还是没找到在哪 ~~~
OH.MyGod 2008-10-23 15:10
晕。。。。怎么没早看到呢。。。。。。。。。
桀顺豪 2008-12-18 12:53
喜欢
同意楼上的.
[img]http://www.dingxiang.name/images/default/sigline.gif[/img]
[url=http://www.keepc.com/voip.htm]网络电话[/url]专家——权威[url=http://www.keepc.com/voip.htm]免费网络电话[/url]、[url=http://www.keepc.com/down/index.htm]免费打电话[/url]信息大全