版主大大:
我是用benba大大的首页N格的版本,
https://discuz.dismall.com/viewth ... p;extra=&page=1
但自己想在文章前面加上主题分类,或是版块名称在文章前头,以下是我的代码:
Index.php ( 以新贴为例)
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
//新貼
$hack_cut_str = 100; //標題字數
$hack_cut_strauthor = 9;
$new_post_threadlist = array();
$nthread = array();
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.dateline DESC LIMIT 0, 10");
$query1 = $db->query("SELECT a.name,b.typeid FROM {$tablepre}threadtypes a, {$tablepre}threads b where b.typeid=a.typeid AND b.fid not in (0) AND b.displayorder not in (-1,-2) ORDER BY b.dateline DESC LIMIT 0, 10");
while(($nthread = $db->fetch_array($query))&&($ntypeids = $db->fetch_array($query1))) {
$nthread['forumname'] = ereg_replace('<[^>]*>','',$nthread['name']);
$nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
$nthread['view_author'] = cutstr($nthread['author'],$hack_cut_strauthor);
$nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
$nthread['lastreplytime'] = gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
$nthread['typename'] = $ntypeids['name'];
if($nthread['highlight']) {
$string = sprintf('%02d', $nthread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$nthread['highlight'] = 'style="';
$nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
$nthread['highlight'] .= '"';
} else {
$nthread['highlight'] = '';
}
$new_post_threadlist[] = $nthread;
}
=========================================================================================
discuz.htm
<div id="top1" style="display:block;">
<!--{loop $new_post_threadlist $nthread}-->
<!--{if $nthread[replies]}-->
<div style="overflow: hidden;height: 20px;width: 100%;">[<a href='forumdisplay.php?fid=$nthread[fid]&filter=type&typeid=$nthread[typeid]'><span style="color:#666666">$nthread[typename]</span></a>] <a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='最新帖子 {LF}所在論壇: $nthread[forumname]{LF}主題標題: $nthread[subject] {LF}主題作者: $nthread[author]{LF}發表時間: $nthread[date]{LF}瀏覽次數: $nthread[views] 次 {LF}回復次數: $nthread[replies] 次{LF}最後回復: $nthread[lastreplytime]{LF}{lang lastpost}: $nthread[lastposter]'>$nthread[view_subject]</a></div>
<!--{else}-->
<div style="overflow: hidden;height: 20px;width: 100%;">[<a href='forumdisplay.php?fid=$nthread[fid]&filter=type&typeid=$nthread[typeid]'><span style="color:#666666">$nthread[typename]</span></a>] <a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='最新帖子 {LF}所在論壇: $nthread[forumname]{LF}主題標題: $nthread[subject] {LF}主題作者: $nthread[author]{LF}發表時間: $nthread[date]{LF}瀏覽次數: $nthread[views] 次 {LF}回復次數: $nthread[replies] 次{LF}最後回復: 暫時沒有回復'>$nthread[view_subject]</a></div>
<!--{/if}-->
<!--{/loop}-->
</div>
修改後却变成以下图片:
未修改前是像这样,有发贴作者,但改後连作者都没了!
想请问版大,是不是我抓取的代码有问题,或是应该以什麽样的方式去做才是正常能抓到主题分类或是版块名称并放置在N格文章前头,
百忙之中打扰您了,感谢您! |