在DISCUZ 官方論壇上看見有這么一個有用的帖子“【SQL標記】DEDE首頁調用DZ論壇圖片的方法 ”
但是現在的論壇版本已經升級了,嘿,我們得重新做一個咯。因為新版本已經整合,所以數據庫表跟以前也是不一樣的,所以偷偷進入數據庫看了一下表,對比一下,還有文件的目錄地址,就得出了新的調用方法。
{dede:sql sql="SELECT`pre_forum_attachment`.`aid`, `pre_forum_attachment`.`attachment`,`pre_forum_thread`.`tid`, `pre_forum_thread`.`fid`, `pre_forum_thread`.`subject` FROM `pre_forum_attachment` LEFT JOIN `pre_forum_thread` ON `pre_forum_thread`.`tid`=`pre_forum_attachment`.`tid` WHERE `pre_forum_attachment`.`readperm`='0' AND `displayorder`>='0' AND `filetype`='image/pjpeg' GROUP BY tid LIMIT 0,1 "} <a href="/x1/viewthread.php?tid=[field:tid /]"> <img src="/x1/data/attachment/forum/[field:attachment/]" ALT="[field:subject/]" width="100" height="80" border="0" /> </A> {/dede:sql} |
說明:<a href="/x1/viewthread.php?tid=[field:tid /]"> //x1為論壇目錄,如果在bbs文件夾下請改為:
<a href="/bbs/viewthread.php?tid=[field:tid /]">
定義圖片的寬和高:
<img src="/x1/data/attachment/forum/[field:attachment/]" ALT="[field:subject/]" width="100" height="80" border="0" />