Discuz如何让帖子列表的标题显示帖子附件中的图片
Discuz的代码还是比较容易看懂的。关键是要找到需要改的地方。
第1步:
forumdisplay.php,用来准备要显示的帖子列表,然后用forumdisplay.htm作为显示模板。
找到forumdisplay.php中的:
$query = $sdb->query("SELECT t.* FROM {$tablepre}threads t
WHERE t.fid='$fid' $filteradd AND $displayorderadd
ORDER BY t.displayorder DESC, t.$orderby $ascdesc
LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");
替换为:
$query = $sdb->query("SELECT t.*,min(att.attachment) as attm FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid
LEFT JOIN {$tablepre}attachments att ON att.tid=t.tid
WHERE t.fid='$fid' $filteradd AND $displayorderadd
GROUP BY t.tid
ORDER BY t.displayorder DESC, t.$orderby $ascdesc
LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");
意思很简单,把附件表中对应第一个附件选出来。这里有一点要注意,需要考虑附件类型,加一个图片类型的where条件即可。
第二步:
修改forumdisplay.htm
把第237行的:
<span id="thread_$thread[tid]"><a href="viewthread.php?tid=$thread[tid]&extra=$extra"$thread[highlight]>$thread[subject]</a></span>
替换为:
<span id="thread_$thread[tid]"><a href="viewthread.php?tid=$thread[tid]&extra=$extra"$thread[highlight]><image width="100px" height="100px" src="attachments/$thread[attm]"/>$thread[subject]</a></span>
加个图片到链接里。
完成。
最后更新于 2011-04-09 10:58:15 并被添加「Discuz dz」标签,已有 44673 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
测试过了,可以用哦~O(∩_∩)O谢谢了。就是图片缩略的变形了.