久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區

標題: 求助,如何在主題列表頁面-每個主題列表下添加4張附件圖片。 [打印本頁]

作者: 1544765    時間: 2024-3-19 16:33
標題: 求助,如何在主題列表頁面-每個主題列表下添加4張附件圖片。
不使用插件的情況下,修改forumdisplay.php文件實現每個主題列表下顯示4張附件圖片,圖片顯示順序按帖子內圖片附件順序排序。


以官方列表為例:這樣的顯示過于單調。
(, 下載次數: 8)


最終我需要顯示的效果如下:
(, 下載次數: 9)


請問有大神知道應該怎么修改嗎?實在是找不到相應的教程才提問的。

作者: 科站網    時間: 2024-3-19 16:55
https://addon.dismall.com/plugin ... on=9252YMBQIXFBIMJW
作者: 1544765    時間: 2024-3-19 16:57
發現不是forumdisplay.php文件  是 forumdisplay_list_box.php文件
作者: 1544765    時間: 2024-3-19 17:32
科站網 發表于 2024-3-19 16:55
https://addon.dismall.com/plugins/qu_forumimglist.html?union=9252YMBQIXFBIMJW

謝謝 但是我不想使用插件
作者: onetheme    時間: 2024-3-19 18:01
插件不好嗎? 沒基礎搞不了,可以有償實現!需要的話聯系QQ
作者: luolongwei    時間: 2024-3-20 22:35
discuz x3.4/x3.3帖子列表頁調用帖子內容圖片附件(多圖)

1、找到forum/forumdisplay_list.htm文件,打開并按照以下方法進行編輯;
2、打開forumdisplay_list.htm文件后,找到
  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]'"));}-->
  2. <!--{if $tbid}-->
  3. <!--{eval $picount = DB::fetch_all("SELECT aid FROM ".DB::table('forum_attachment_'.$tbid.'')." WHERE `tid`= '$thread[tid]' AND `isimage`=1;");}-->
  4. <!--{eval $picnum = count($picount);}-->
  5. <!--{if $picnum < 3}-->
  6. <!--{eval $litpicnum = '1';}-->
  7. <!--{elseif $picnum > 2 && $picnum < 6}-->
  8. <!--{eval $litpicnum = '3';}-->
  9. <!--{elseif $picnum > 5}-->
  10. <!--{eval $litpicnum = '6';}-->
  11. <!--{/if}-->
  12. <!--{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;");}-->
  13. <!--{/if}-->
復制代碼
3、在forumdisplay_list.htm中繼續找到
  1. <!-- end of table "forum_G[fid]" branch 1/3 -->
復制代碼
在這段代碼上方找到最靠近的</tr>,在此之后添加:
  1. <!--{if $tbid}-->
  2. <tr>
  3. <td></td>
  4. <td></td>
  5. <td colspan="4">
  6. <!--{loop $covers $thecover}-->
  7. <!--{if $litpicnum == 1}-->
  8. <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>
  9. <font class="z">This is what it is like to be with Trump.</font>
  10. <!--{else}-->
  11. <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>
  12. <!--{/if}-->
  13. <!--{/loop}-->
  14. </td>
  15. </tr>
  16. <!--{/if}-->
復制代碼
4、繼續找到:
  1. <!--{if !$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])}-->
  2. <!--{if $thread['related_group'] == 0 && $thread['closed'] > 1}-->
  3. <!--{eval $thread[tid]=$thread[closed];}-->
  4. <!--{/if}-->
  5. <!--{if $groupnames[$thread[tid]]}-->
  6. <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>
  7. <!--{/if}-->
  8. <!--{/if}-->
復制代碼
在之后添加
  1. <!--{if $tbid && !$picnum == 0}--><span style="color:red;"><!--{$picnum}-->P</span><!--{/if}--></a>
復制代碼
保存后完成!效果如下圖所示。
(, 下載次數: 9)


【代碼分析】:
1、上面介紹的代碼中,有一段是設置圖片顯示數量的邏輯代碼,如下
  1. <!--{if $picnum < 3}-->
  2. <!--{eval $litpicnum = '1';}-->
  3. <!--{elseif $picnum > 2 && $picnum < 6}-->
  4. <!--{eval $litpicnum = '3';}-->
  5. <!--{elseif $picnum > 5}-->
  6. <!--{eval $litpicnum = '6';}-->
復制代碼
意思是當內容中圖片數量小于3時,顯示1張圖片;
當圖片數量大于2小于6時,圖片顯示3張;
當圖片數量大于5時,顯示6張圖片。大家可以按照需求進行修改。
2、代碼中設置的圖片長和寬都是100px,width="100" height="100"如果有需要可以按照自己的想法修改數值。





作者: babyfacer    時間: 2024-3-20 23:32
luolongwei 發表于 2024-3-20 22:35
discuz x3.4/x3.3帖子列表頁調用帖子內容圖片附件(多圖)

1、找到forum/forumdisplay_list.htm文件,打開 ...

666,這個不錯




歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) Powered by Discuz! W1.0