Answer the question
In order to leave comments, you need to log in
How to insert counter in smarty loop?
There is a cycle on smart that displays a specific group.
{get_banner var=banner1 group=1}
{if $banner1->items}
{foreach $banner1->items as $bi}
<div class="col-md-8">
{if $bi->url}
<a href="{$bi->url}" target="_blank">
{/if}
{if $bi->image}
<img class="img-responsive" src="{$config->banners_images_dir}{$bi->image}" alt="{$bi->alt}" title="{$bi->title}">
{else}
{$bi->description}
{/if}
{if $bi->url}
</a>
{/if}
</div>
{/foreach}
{/if}
{get_banner var=banner2 group=2}
{if $banner2->items}
{foreach $banner2->items as $bi}
Answer the question
In order to leave comments, you need to log in
{assign var=val value=1} - before foreach
{assign var=val value=$val+1} - inside foreach
Try like this:
{foreach from=$banner1->items item=$bi name=fi}
{$smarty.foreach.fi.index}|{$smarty.foreach.fi.iteration}
...
{if $smarty.foreach.fi.iteration = 99}{break}{/if}
{/foreach}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question