0

我=0。我想在 foreach 中创建 tab1、tab2、tab3 等,如果 i=1 则首先 echo class="active" < li >。怎么做?

{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 则 echo class="active")

><a href="#

选项卡1

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

选项卡1">

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

这是HTML源代码

4

2 回答 2

2

此答案基于您的标题,因为您的 HTML 不可读

{section name=foo loop=5} 
    {$smarty.section.foo.iteration} 
{/section}
于 2012-10-17T14:46:57.410 回答
0

{foreach from=$complexElements key="complexElementKey" item="complexElementItem"} 的 key 内的 complexElementKey 将是循环 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
于 2012-10-18T13:01:17.527 回答