2012-10-17 94 views
0

i = 0。我想在foreach中使tab1,tab2,tab3等等,並且如果i = 1,那麼在第一個< li>處回顯class =「active」。如何做到這一點?i = i + 1裏面foreach for smarty

{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 

(若設爲i = 1,則回聲類= 「活性」)

><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

回答

0

complexElementKey內的鍵{的foreach從= $ complexElements鍵= 「complexElementKey」 項= 「complexElementItem」}將循環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 
2

這個答案是基於您的稱呼,是因爲你的HTML不是可讀

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

對不起。我不想tab12345。循環在{foreach}中。第一個循環是tab1。第二個循環是tab2 ... – user1732217

+0

我附加了html代碼。 – user1732217

相關問題