i = i + 1在foreach内部为smarty

i=0. I would like to make tab1, tab2,tab3, and so on inside foreach and also if i=1 then echo class="active" at first < li >. How to make it?

{elseif $complexField == "KeySkills"} 
<ul> 
{foreach from=$complexElements key="complexElementKey" item="complexElementItem"} 
{foreach from=$form_fields item=form_field} 
{if $form_field.caption == "Key personal skill"} 
<li 

(if i=1 then echo class="active")

><a href="#

tab1

" data-toggle="tab">{display property=$form_field.id complexParent=$complexField complexStep=$complexElementKey}    </a></li> 
{/if} 
{/foreach} 
{/foreach} 
</ul> 
<div class="tab-content" style="min-height:470px;"> 
{foreach from=$complexElements key="complexElementKey" item="complexElementItem"} 

{if $form_field.caption == "Percentaged Key Skill" || $form_field.caption == "Skill Detail"} 
<div class="tab-pane fade active in" id="

tab1">

<div class="item_top"> 
<p> {display property=$form_fields.SkillDetail.id complexParent=$complexField complexStep=$complexElementKey} </p> 
<div class="donutchart2" data-percent="{display property=$form_fields.PercentKeySkill.id complexParent=$complexField complexStep=$complexElementKey}"></div> 
</div> 
</div> 
{/if} 

{/foreach} 
</div>

Here is HTML source code

complexElementKey inside key of {foreach from=$complexElements key="complexElementKey" item="complexElementItem"} will be loop 1,2,3.

<a href="#tab{$complexElementKey}" data-toggle="tab"> will be <a href="#tab1" data-toggle="tab">blablabla

<a href="#tab2" data-toggle="tab"> bsdakdkas

<a href="#tab3" data-toggle="tab">gdfgdfg

This answer is based you your title because your HTML isn't readable

{section name=foo loop=5} 
    {$smarty.section.foo.iteration} 
{/section}