discuz x3.3帖子列表页调用帖子图片附件
代码可以直接写在模板forumdisplay_list.htm里,有不同数量不同样式。
以默认模板为例:
打开模板forum/forumdisplay_list.htm,找到83行左右:
在其下增加
再查找
其上最近的</tr>之后增加
再找到
其下增加
具体的图片显示多少这里↓,<3显示1,>2且<6显示3,>5显示6。
这个是匆忙写的,没注意有没有逻辑漏洞,如有错请提出。
后面具体的样式是这段↓
如果图片数量等于1,后面带个摘要。
否则图片横排铺开。具体数量会按上面的显示。
通常情况下,两种样式即可,1图和多图,即1图显示在左右,多图在下面铺开。
如果多种样式,<!--{if $litpicnum == 数量}-->此数量时的表现形式</if>
当然,这的数量$litpicnum是受上面的代码中与$picnum关系的限定。
$picnum是实际总数量,$litpicnum是经过判断后允许显示的数量。
以默认模板为例:
打开模板forum/forumdisplay_list.htm,找到83行左右:
- <!--{loop $_G['forum_threadlist'] $key $thread}-->
在其下增加
-
<!--{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}-->
再查找
- <!-- end of table "forum_G[fid]" branch 1/3 -->
其上最近的</tr>之后增加
-
<!--{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}-->
再找到
-
<!--{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}-->
其下增加
- <!--{if $tbid && !$picnum == 0}--><span style="color:red;"><!--{$picnum}-->P</span><!--{/if}--></a>
具体的图片显示多少这里↓,<3显示1,>2且<6显示3,>5显示6。
-
<!--{if $picnum < 3}--> <!--{eval $litpicnum = '1';}--> <!--{elseif $picnum > 2 && $picnum < 6}--> <!--{eval $litpicnum = '3';}--> <!--{elseif $picnum > 5}--> <!--{eval $litpicnum = '6';}--> <!--{/if}-->
这个是匆忙写的,没注意有没有逻辑漏洞,如有错请提出。
后面具体的样式是这段↓
-
<!--{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 == 数量}-->此数量时的表现形式</if>
当然,这的数量$litpicnum是受上面的代码中与$picnum关系的限定。
$picnum是实际总数量,$litpicnum是经过判断后允许显示的数量。
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
热门教程
discuz电脑版、手机版去除标题title中的PoweredbyDisc2018-12-27
Discuz 触屏手机版支持视频播放的方法2018-12-27
discuz手机版支持视频播放的修改方法2018-12-27
Discuz! 程序 X3.2、X3.3升级3.4教程2018-12-27
discuz X3以及X3.4论坛搬家完美详细教程2019-01-02
怎么开启手机版2018-12-25
去掉Discuz论坛底部的Powered 等版权信息2018-12-27
discuz! x3.4插件位置DZ论坛X3版本插件在哪个文件夹?2018-12-26
Mysql修改端口号后织梦dedecms的修改方法2018-12-27
Discuz!X3.2论坛实现全站HTTPS终极方法教程2018-12-28