1

Basically this code gives me < li > 1 2 3 4 < / li > < li > 1 2 3 4 < / li > < li > 1 2 < / li >. So basically at end i need to put 3 and 4 with different result for example, < li >1 2 empty empty< / li > - since there should be always 4 results per one < li >< / li >, it is tricky because loop gives as much as it get's and sometimes there are less :).

<ul>

{section name=attribs loop=$AccountHistory}
   {if $smarty.section.attribs.index % 4 == 0 or $smarty.section.attribs.first}
     <li>
   {/if}

      {$smarty.section.iteration}

   {if $smarty.section.attribs.index % 4 == 3 or $smarty.section.attribs.last}
    </li>
   {/if}

{/section}

</ul>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Cameleon
  • 59
  • 10

1 Answers1

1

Maybe something like this into the loop?

{if $smarty.section.attribs.last && ($smarty.section.attribs.index % 4) >0}
   {section name=tmp loop=(4-($smarty.section.attribs.index % 4)) start=(( $smarty.section.attribs.index % 4) + 1)}
      {$smarty.section.tmp.index}
   {/section}
{/if}
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56