2007-9-26 09:58
qingfeng129
请教sai一个问题
sai, 请教你一个问题.
举例...如何在首页即红线位置显示读编室整个大版块1周之内的新帖? 字体大小和颜色根据回复决定.
具体的语句能否告知?
thanks!
hope to hear from you soon!
[img]http://i21.tinypic.com/ddngi9.jpg[/img]
2007-9-26 22:29
Sai
给你一个很久以前写的function(似乎0724的index.php已经包含?),每个大类都会有一个查询,有待优化
[code]
function rand_topic($fup) {
global $db, $_DCACHE, $timestamp, $tablepre, $timeoffset, $maxbdays, $smcols, $smrows,$discuz_uid, $groupid, $fid, $indexname;
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
foreach($_DCACHE['forums'] as $forum_all) {
if($forum_all['type'] == 'group' ) {
$visible[$forum_all['fid']] = true;
} elseif($forum_all['type'] == 'forum' && $forum_all['fup']== $fup && isset($visible[$forum_all['fup']]) && (!$forum_all['viewperm'] || ($forum_all['viewperm'] && forumperm($forum_all['viewperm'])) || strstr($forum_all['users'], "\t$discuz_uid\t"))) {
$_forums[] =$forum_all['fid'];
$visible[$forum_all['fid']] = true;
}
}
$forum_list_sql = implode(',', $_forums);
$forum_topic_list = array();
$query = $db->query("SELECT t.tid, t.fid, t.author,t.subject,t.replies FROM {$tablepre}threads t WHERE t.displayorder!='-1' and t.fid IN ({$forum_list_sql}) ORDER BY rand() LIMIT 0, 20");
while($idx_forum_topic = $db->fetch_array($query)) {
$idx_forum_topic['uid'] = $idx_forum_topic['uid'];
$idx_forum_topic['author'] = $idx_forum_topic['author'] ? $idx_forum_topic['author'] : '游客';
$idx_forum_topic['subjectc'] = cutstr($idx_forum_topic['subject'], 50);
$idx_forum_topic['size'] = vxGetItemSize($idx_forum_topic['replies']).'px';
if ($idx_forum_topic['replies'] < 5){
$idx_forum_topic['csscolor'] = rand_gray();
}else{
$idx_forum_topic['csscolor'] = rand_color();
}
$forum_topic_list[] = $idx_forum_topic;
}
if(is_array($forum_topic_list)) {
foreach($forum_topic_list as $toploop) {
echo '<span class="tip_i"><a href="viewthread.php?tid='.$toploop['tid'].'" style="color: '.$toploop['csscolor'].';font-size: '.$toploop['size'].';" class="var">'.$toploop['subject'].'</a> </span>';} }
}
[/code]
2007-9-27 00:26
qingfeng129
@sai
ok,got it...thank you so much