国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > Discuz > 正文

discuz x3.3帖子列表頁調用帖子圖片附件

2024-09-11 09:05:37
字體:
來源:轉載
供稿:網友
代碼可以直接寫在模板forumdisplay_list.htm里,有不同數量不同樣式。
以默認模板為例:
打開模板forum/forumdisplay_list.htm,找到83行左右:
  1. <!--{loop $_G['forum_threadlist'] $key $thread}-->
復制代碼
在其下增加
  1. <!--{eval $tbid = DB::result(DB::query("SELECT tableid FROM ".DB::table('forum_attachment')." WHERE `tid`= '$thread[tid]'"));}--><!--{if $tbid}--><!--{eval $picount = DB::fetch_all("SELECT aid FROM ".DB::table('forum_attachment_'.$tbid.'')." WHERE `tid`= '$thread[tid]' AND `isimage`=1;");}--><!--{eval $picnum = count($picount);}--><!--{if $picnum < 3}--><!--{eval $litpicnum = '1';}--><!--{elseif $picnum > 2 && $picnum < 6}--><!--{eval $litpicnum = '3';}--><!--{elseif $picnum > 5}--><!--{eval $litpicnum = '6';}--><!--{/if}--><!--{eval $covers = DB::fetch_all("SELECT attachment,aid,description FROM ".DB::table('forum_attachment_'.$tbid.'')." WHERE `tid`= '$thread[tid]' AND `isimage`=1 LIMIT 0,$litpicnum;");}--><!--{/if}-->

再查找
  1. <!-- end of table "forum_G[fid]" branch 1/3 -->
復制代碼
其上最近的</tr>之后增加
  1. <!--{if $tbid}--><tr><td></td><td></td><td colspan="4"><!--{loop $covers $thecover}--><!--{if $litpicnum == 1}--><a href="forum.php?mod=viewthread&tid=$thread[tid]" class="z pipe" title="$thecover[aid]"><img src="data/attachment/forum/$thecover['attachment']" width="100" height="100"/></a><font class="z">This is what it is like to be with Trump.</font><!--{else}--><a href="forum.php?mod=viewthread&tid=$thread[tid]" class="z pipe" title="$thecover[aid]"><img src="data/attachment/forum/$thecover['attachment']" width="100" height="100"/></a><!--{/if}--><!--{/loop}--></td></tr><!--{/if}-->
復制代碼
再找到
  1. <!--{if !$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}--><!--{if $thread['related_group'] == 0 && $thread['closed'] > 1}--><!--{eval $thread[tid]=$thread[closed];}--><!--{/if}--><!--{if $groupnames[$thread[tid]]}--><span class="fromg xg1"> [{lang from}: <a href="forum.php?mod=group&fid={$groupnames[$thread[tid]][fid]}" target="_blank" class="xg1">{$groupnames[$thread[tid]][name]}</a>]</span><!--{/if}--><!--{/if}-->
復制代碼
其下增加
  1. <!--{if $tbid && !$picnum == 0}--><span style="color:red;"><!--{$picnum}-->P</span><!--{/if}--></a>
復制代碼結束。

具體的圖片顯示多少這里↓,<3顯示1,>2且<6顯示3,>5顯示6。
  1. <!--{if $picnum < 3}--><!--{eval $litpicnum = '1';}--><!--{elseif $picnum > 2 && $picnum < 6}--><!--{eval $litpicnum = '3';}--><!--{elseif $picnum > 5}--><!--{eval $litpicnum = '6';}--><!--{/if}-->

這個是匆忙寫的,沒注意有沒有邏輯漏洞,如有錯請?zhí)岢觥?br />
后面具體的樣式是這段↓
  1. <!--{if $litpicnum == 1}--><a href="forum.php?mod=viewthread&tid=$thread[tid]" class="z pipe" title="$thecover[aid]"><img src="data/attachment/forum/$thecover['attachment']" width="100" height="100"/></a><font class="z">This is what it is like to be with Trump.</font><!--{else}--><a href="forum.php?mod=viewthread&tid=$thread[tid]" class="z pipe" title="$thecover[aid]"><img src="data/attachment/forum/$thecover['attachment']" width="100" height="100"/></a><!--{/if}-->
復制代碼
如果圖片數量等于1,后面帶個摘要。
否則圖片橫排鋪開。具體數量會按上面的顯示。

通常情況下,兩種樣式即可,1圖和多圖,即1圖顯示在左右,多圖在下面鋪開。
如果多種樣式,<!--{if $litpicnum == 數量}-->此數量時的表現(xiàn)形式</if>
當然,這的數量$litpicnum是受上面的代碼中與$picnum關系的限定。
$picnum是實際總數量,$litpicnum是經過判斷后允許顯示的數量。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 新宾| 黎平县| 萍乡市| 榆中县| 阜平县| 灵武市| 泰兴市| 石家庄市| 马公市| 秦安县| 吉木萨尔县| 凌源市| 西华县| 高安市| 岢岚县| 洪泽县| 洪洞县| 阿勒泰市| 烟台市| 炎陵县| 灵丘县| 扎赉特旗| 城固县| 望城县| 长阳| 南木林县| 舞阳县| 房产| 安福县| 滨州市| 常山县| 鄂伦春自治旗| 阿克| 桂东县| 东丽区| 比如县| 莆田市| 洛南县| 延吉市| 金塔县| 平潭县|