本帖最后由 zhuisu 于 2009-11-2 21:51 编辑
对对,是上下篇,不是分页,那个链接我没有修改,是默认的啊
我认为ss7是这个bug
你这个相当于重新原来的batch.common.php?action=viewnews&op=up&itemid=556&catid=5无用处了
我重新写了一个,在viewnews.php文件增加:- //调上标题
- $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 = '已经第1了';
- //调上标题id
- $title_aid = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT itemid FROM '.tname('spaceitems').' WHERE itemid < \''.$itemid.'\' AND catid = \''.$thecat['catid'].'\' AND folder=\'1\' AND type=\'news\' ORDER BY itemid DESC LIMIT 0,1'), 0);
- //调下标题
- $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 = '下一篇:未';
- //调下一标题id
- $title_bid = $_SGLOBAL['db']->result($_SGLOBAL['db']->query('SELECT itemid FROM '.tname('spaceitems').' WHERE itemid > \''.$itemid.'\' AND catid = \''.$thecat['catid'].'\' AND folder=\'1\' AND type=\'news\' ORDER BY itemid LIMIT 0,1'), 0);
- //代码结束
复制代码 然后在templates/default/news_view.html.php修改:- <div id="article_pn"><a class="box_l" href="{S_URL}/viewnews-$title_aid.html">上一篇:$title_a</a><a class="box_r" href="{S_URL}/viewnews-$title_bid.html">下一篇:$title_b</a></div>
复制代码 效果好啊:http://www.bianjichuban.com/info/viewnews-555.html
新咨询discuz.dismall.com:
1、这样直接显示了,不过不清楚为什么href="{S_URL}/viewnews-$title_aid.html"显示时候却是url/viewnews-1之类的,后缀.html却不显示,有知道是怎么回事的吗
注:经过摸索,找到原因了,似乎用viewnews-{$title_aid}.html就可以了,不用{}的话就不可以,有谁可以解释一下这个php
2、此外,请教一个php读取数据库操作的问题:
在上面我用了多个变量分别调出$title_b标题和$title_bid编号,似乎重复操作数据库,不友好。怎么在查询的时候SELECT subject+‘|’+itemid,比如得到结果“标题|123”,然后用split分割一下,这样一此读取两个内容,然后分割给两个变量,减少数据库操作啊?,麻烦帮忙啊,谢谢 |