1

我有一系列图像:

1-3 是主要图像。3+ 是缩略图。

Q) 如何将拇指分成 2 行。

例如:

<div class="main-images">
{section name="i" loop=$images.rows}
{assign var="rows" value=$images.rows[i]}
    {if $smarty.section.i.index <= 2}
    <img />
    {/if}
{/section}
</div>

<div class="thumbs-images">
{math assign=thumbs_count equation="total - other" total=$images.rowcount other=3}
{section name="i" loop=$images.rows}
{assign var="rows" value=$images.rows[i]}
    {if $smarty.section.i.index >= 3}
    <img />
    {/if}
{/section}
</div>

所以我需要添加一些东西{if $thumbs_count >= $smarty.section.i.index}<div style="clear:both" />{/if},这样它就会出现在第二个循环的一半。

4

1 回答 1

2

设法弄清楚这一点。

{math assign="total_row_split" equation="floor((total - main) / division)" total=$images.rows|@count division=2 main=3}
{counter start=0 print=false assign="thumbs_count"}
{section name="i" loop=$images.rows}
{assign var="rows" value=$images.rows[i]}
    {if $smarty.section.i.index >= 3}
    {if $thumbs_count == $total_row_split}<br style="clear:both" />{/if}
    <a href="{$HOME}/get/image{$rows.filename.fvalue}" rel="fancy" title="{$rows.title.value|default:$product.name.fvalue}">
        <img src="{$HOME}/get/image/120{$rows.filename.fvalue}" alt="{$rows.title.value|default:$product.name.fvalue} Picture" />
    </a>
    {counter print=false}
    {/if}
{/section}
于 2012-12-02T20:21:59.470 回答