$config_overwrite

默认为true,设置为true时, 配置文件 内的变量将覆盖每个相同名称的变量值。 当false时,相同名称的变量将合并成一个数组。 这在你希望把配置文件内变量变成数组来循环使用的时候非常有用。


Example 13.2. #变量#数组

以下例子是,当$config_overwrite为false时,使用{cycle}来显示一个在每列上交替红/绿/蓝三种颜色的表格。

配置文件

  1. # 行列的颜色
  2. rowColors = #FF0000
  3. rowColors = #00FF00
  4. rowColors = #0000FF
  5.  

{section}循环的模板。

  1. <table>
  2. {section name=r loop=$rows}
  3. <tr bgcolor="{cycle values=#rowColors#}">
  4. <td> ....etc.... </td>
  5. </tr>
  6. {/section}
  7. </table>
  8.  

参见 {config_load}, getConfigVars(), clearConfig(), configLoad()配置文件

原文: https://www.smarty.net/docs/zh_CN/variable.config.overwrite.tpl