如果需要實(shí)現(xiàn)該呈現(xiàn)方式,我們需要首先了解discuz封面圖片存儲原理:
discuz沒有將主題列表封面路徑存在數(shù)據(jù)表中,只是在pre_forum_thread表中存了一個(gè)cover標(biāo)識。然后用getthreadcover 函數(shù)調(diào)取,diy調(diào)用的圖片也會產(chǎn)生縮略圖,可以設(shè)置縮略圖的質(zhì)量。
封面圖片存儲路徑格式:data/attachment/forum/threadcover/43/ec/81.jpg
getthreadcover 函數(shù):
function getthreadcover($tid, $cover = 0, $getfilename = 0) {
global $_G;
if(empty($tid)) {
return '';
}
$coverpath = '';
$covername = 'threadcover/'.substr(md5($tid), 0, 2).'/'.substr(md5($tid), 2, 2).'/'.$tid.'.jpg';
if($getfilename) {
return $covername;
}
if($cover) {
$coverpath = ($cover < 0 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$covername;
}
return $coverpath;
}
|
文件路徑:/source/function/function_forum.php
復(fù)制代碼
實(shí)現(xiàn)方法:
修改:/source/language/home/lang_template.php
添加like 喜歡或查看
修改:/template/default/home/space_thread.htm
處理封面圖:
{eval
$covername = 'threadcover/'.substr(md5($thread[tid]), 0, 2).'/'.substr(md5($thread[tid]), 2, 2).'/'.$thread[tid].'.jpg';
$coverpath = ($cover < 0 ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$covername;
}
|
圖片列表
<li style="width: 227px; left: 0px; top: 0px;float:left;">
<div class="c cl">
<a class="z" title="$thread[subject]" onclick="atarget(this)" href="forum.php?mod=viewthread&tid=$thread[tid]">
<img width="203" alt="$thread[subject]" src="{eval echo $coverpath;}">
</a>
</div>
<h3 class="xw0">
<a href="forum.php?mod=viewthread&tid=$thread[tid]" onclick="atarget(this)" target="_blank" {if $thread['displayorder'] == -1}class="recy"{/if}>$thread[subject]</a>
</h3>
<div class="auth cl">
<cite class="xg1 y">
{lang like}: <em>$thread[views]</em> {lang reply}: <a title="0 回復(fù)" href="forum.php?mod=viewthread&tid=$thread[tid]">$thread[replies]</a>
</cite>
<a href="home.php?mod=space&uid=$thread[authorid]" target="_blank">$thread[author]</a>$thread[dateline]</div>
</li>
|