[color=#000][font="]有好多[/font][/color][font="]站长[/font][color=#000][font="]在问如何让帖子列表显示帖内的附件图,调用数量可以随意设置,这里贴出方法:[/font][/color]
[align=left][color=#000][font="]需要修改的文件,template/default/forum/forumdisplay_list.htm(这里以默认[color=rgb(68, 68, 68) !important][url=http://www.dtyuanma.com/forum-2-1.html]模板[/url][/font]为例子,其他模板可以自行参考)[/color][/align][align=left][color=#000][font="]找到这段代码:[/font][/color][/align][code]<!--{loop $_G['forum_threadlist'] $key $thread}-->
[/code][color=#000][font="]在下面增加这端代码:[/font][/color]
[code]<!--{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}-->
[/code][color=#000][font="]然后再查找到这段代码:[/font][/color]
[code]<!-- end of table "forum_G[fid]" branch 1/3 -->
[/code][color=#222527][font=Helvetica, Arial, "]其上最近的</tr>之后增加[/font][/color]
[color=#222527][font=Helvetica, Arial, "][code]<!--{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}-->
[/code]再查找:[/font][/color]
[color=#222527][font=Helvetica, Arial, "][code]<!--{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}-->
[/code]在下面增加这段:[/font][/color][color=#222527][font=Helvetica, Arial][hide][/font][/color][font=Helvetica, Arial][color=#222527]
[/color][/font][color=#222527][font=Helvetica, Arial, "][code]<!--{if $tbid && !$picnum == 0}--><span style="color:red;"><!--{$picnum}-->P</span><!--{/if}--></a>
[/code][indent][/hide][/indent]
[/font][/color][color=#222527][font=Helvetica, Arial, "]这样修改就结束了[/font][/color]
[color=#222527][font=Helvetica, Arial, "]----------以下为代码说明---------[/font][/color]
[color=#222527][font=Helvetica, Arial, "][code]<!--{if $picnum < 3}-->
<!--{eval $litpicnum = '1';}-->
<!--{elseif $picnum > 2 && $picnum < 6}-->
<!--{eval $litpicnum = '3';}-->
<!--{elseif $picnum > 5}-->
<!--{eval $litpicnum = '6';}-->
<!--{/if}-->[/code]具体的图片显示多少这里↓,<3显示1,>2且<6显示3,>5显示6。[/font][/color]
[color=#222527][font=Helvetica, Arial, "]
[/font][/color]
[color=#222527][font=Helvetica, Arial, "]----------[/font][/color][color=#000][font="]以下为[/font][/color][color=#000][font="]代码说明---------[/font][/color]
[color=#222527][font=Helvetica, Arial, "][code]<!--{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}-->[/code][/font][/color][color=#222527][font=Helvetica, Arial, "]如果图片数量等于1,后面带个摘要。
否则图片横排铺开。具体数量会按上面的显示。
通常情况下,两种样式即可,1图和多图,即1图显示在左右,多图在下面铺开。
如果多种样式,<!--{if $litpicnum == 数量}-->此数量时的表现形式</if>
当然,这的数量$litpicnum是受上面的代码中与$picnum关系的限定。
$picnum是实际总数量,$litpicnum是经过判断后允许显示的数量。[/font][/color]
[color=#222527][font=Helvetica, Arial, "]
[/font][/color]
|