$config_overwrite
默认为true,设置为true时, 配置文件 内的变量将覆盖每个相同名称的变量值。 当false时,相同名称的变量将合并成一个数组。 这在你希望把配置文件内变量变成数组来循环使用的时候非常有用。
以下例子是,当$config_overwrite
为false时,使用{cycle}
来显示一个在每列上交替红/绿/蓝三种颜色的表格。
配置文件
- # 行列的颜色
- rowColors = #FF0000
- rowColors = #00FF00
- rowColors = #0000FF
带 {section}
循环的模板。
- <table>
- {section name=r loop=$rows}
- <tr bgcolor="{cycle values=#rowColors#}">
- <td> ....etc.... </td>
- </tr>
- {/section}
- </table>
参见 {config_load}
, getConfigVars()
, clearConfig()
, configLoad()
和配置文件。
原文: https://www.smarty.net/docs/zh_CN/variable.config.overwrite.tpl