{foreach name="catpic" from=$rightcats item="cpic"} {if not $smarty.foreach.last and $smarty.foreach.catpic.iteration is div by 4} {/if} {/foreach}