Monday 21 August 2006 2:40:38 am
Thanks Kristof, One more question? Is it an array or a hash. The reason I am asking is that I am trying to make my search template. The following original search tpl code <select name="SearchSectionID">
<option value="-1">{"Any section"|i18n("design/standard/content/search")}</option>
{section name=Section loop=$section_array }
<option {switch name=sw match=$search_section_id}
{case match=$Section:item.id}
selected="selected"
{/case}
{case}
{/case}
{/switch} value="{$Section:item.id}">{$Section:item.name|wash}</option>
{/section}
</select>
produces <select name="SearchSectionID">
<option value="-1">
Any Section
</option>
<option value="1">
Standard
</option>
<option value="2">
Users
</option>
<option value="3">
Media
</option>
<option value="4">
Setup
</option>
<option value="5">
Design
</option>
</select>
While my newly foreach code <select name="SearchSectionID">
<option value="-1">{"Any section"|i18n("design/standard/content/search")}</option>
{foreach $section_array as $srIndex=>$srSection}
<option {switch name=sw match=$search_section_id}{case match=$srSection.name} selected="selected" {/case} {/switch} value="{$srIndex+1}">{$srSection.name|wash}</option>
{/foreach}
</select>
produces. Note that option value start with 0 i.e. each section is of by 1 due to the fact that the array index starts with 0
<select name="SearchSectionID">
<option value="-1">
Any Section
</option>
<option value="0">
Standard
</option>
<option value="1">
Users
</option>
<option value="2">
Media
</option>
<option value="3">
Setup
</option>
<option value="4">
Design
</option>
</select>
|