请知悉:本文最近一次更新为 10年 前,文中内容可能已经过时。

内网投票,由于之前改进后,内容可以写很多,所以一行显示四个会显得很乱,所以要求要横向展示。动手改模板。

网站目录\template\default\forum\viewthread_poll.htm

<!--{loop $polloptions $key $option}-->
<!--{eval $i++;}-->
<!--{eval $imginfo=$option['imginfo'];}-->
<td valign="bottom" id="polloption_$option[polloptionid]" width="25%">
<div class="polltd cl">
<!--{if $imginfo}-->
<a href="JavaScript:;" title="$imginfo[filename]" >
<img id="aimg_$imginfo[aid]" aid="$imginfo[aid]" src="$imginfo[small]" width="130px" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[setting][showexif]}')" zoomfile="$imginfo[big]" alt="$imginfo[filename]" title="$imginfo[filename]" w="$imginfo[width]" />
</a>
<!--{else}-->
<a href="JavaScript:;" title=""><img src="{IMGDIR}/nophoto.gif" width="130px" /></a>
<!--{/if}-->
<p class="mtn mbn xi2">
<!--{if $_G['group']['allowvote']}-->
<label><input class="pr" type="$optiontype" id="option_$key" name="pollanswers[]" value="$option[polloptionid]" {if $_G['forum_thread']['is_archived']}disabled="disabled"{/if} {if $optiontype=='checkbox'}onclick="poll_checkbox(this)"{else}onclick="$('pollsubmit').disabled = false"{/if} /></label>
<!--{/if}-->
$option[polloption]
</p>
<!--{if $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']}-->
<div class="imgf imgf2">
<span class="jdt" style="width: $option[width]; background-color:#$option[color]">&nbsp;</span>
<p class="imgfc">
<span class="z">$option[votes]{lang debate_poll}</span>
<span class="y">{$option[percent]}% </span>
</p>
</div>
<!--{/if}-->
</div>
</td>
<!--{if $key % 4 == 0 && isset($polloptions[$key])}--></tr><tr><!--{/if}-->
<!--{/loop}-->

改为

<!--{loop $polloptions $key $option}-->
<!--{eval $i++;}-->
<!--{eval $imginfo=$option['imginfo'];}-->
<td valign="bottom" id="polloption_$option[polloptionid]" width="100%">
<div class="polltd cl">
<!--{if $imginfo}-->
<a href="JavaScript:;" title="$imginfo[filename]" >
<img id="aimg_$imginfo[aid]" aid="$imginfo[aid]" src="$imginfo[small]" width="130px" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[setting][showexif]}')" zoomfile="$imginfo[big]" alt="$imginfo[filename]" title="$imginfo[filename]" w="$imginfo[width]" style="float:left;"/>
</a>
<!--{else}-->
<a href="JavaScript:;" title=""><img src="{IMGDIR}/nophoto.gif" width="130px" /></a>
<!--{/if}-->
<p class="mtn mbn xi2" style="float:right;width:75%;">
<!--{if $_G['group']['allowvote']}-->
<label><input class="pr" type="$optiontype" id="option_$key" name="pollanswers[]" value="$option[polloptionid]" {if $_G['forum_thread']['is_archived']}disabled="disabled"{/if} {if $optiontype=='checkbox'}onclick="poll_checkbox(this)"{else}onclick="$('pollsubmit').disabled = false"{/if} /></label>
<!--{/if}-->
$option[polloption]
</p>
<!--{if $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']}-->
<div class="imgf imgf2" style="float:right;width:75%;">
<span class="jdt" style="width: $option[width]; background-color:#$option[color]">&nbsp;</span>
<p class="imgfc">
<span class="z">$option[votes]{lang debate_poll}</span>
<span class="y">{$option[percent]}% </span>
</p>
</div>
<!--{/if}-->
</div>
</td>
<!--{if isset($polloptions[$key])}--></tr><tr><!--{/if}-->
<!--{/loop}-->

既可实现横向展示投票内容,效果如图:

投票横向展示示意图

具体变动了哪些,自己用compare it软件对比下就知道了。其实就是把输出的部分写入了些样式,然后改每四个td输出tr为每个td都输出td。

至此,投票内容已经可以横向展示了。


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《Discuz!-X3-让投票的展示横向展示》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌