:::

2. in_array用法

  1. 語法:{if $current_item|in_array:$selected_array}
  2. 例子:在xoops樣板中產生星期,先準備好預設值
    $weekArr=[1,2,3,4...]
  3. 樣板檔
<div class="span10">
        <{section name=w start=0 loop=7 step=1}>
            <label class="checkbox inline  text-right">
              <input type='checkbox' name="jbt_week[<{$smarty.section.w.index}>]" id="week_<{$smarty.section.w.index}>" value="<{$smarty.section.w.index}>" <{if  $smarty.section.w.index|in_array:$weekArr }>checked="checked"<{/if}>>
              <{if $smarty.section.w.index==0 }><{$smarty.const._MA_JILLBOOKIN_W0}>
              <{elseif $smarty.section.w.index==1 }><{$smarty.const._MA_JILLBOOKIN_W1}>
              <{elseif $smarty.section.w.index==2 }><{$smarty.const._MA_JILLBOOKIN_W2}>
              <{elseif $smarty.section.w.index==3 }><{$smarty.const._MA_JILLBOOKIN_W3}>
              <{elseif $smarty.section.w.index==4 }><{$smarty.const._MA_JILLBOOKIN_W4}>
              <{elseif $smarty.section.w.index==5 }><{$smarty.const._MA_JILLBOOKIN_W5}>
              <{else}><{$smarty.const._MA_JILLBOOKIN_W6}>
              <{/if}>
            </label>
        <{/section}>
</div>