Revision 148 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
# Config FilesConfig files are handy for designers to manage global template variablesfrom one file. One example is template colors. Normally if you wanted tochange the color scheme of an application, you would have to go througheach and every template file and change the colors. With a config file,the colors can be kept in one place, and only one file needs to beupdated.```ini# global variablespageTitle = "Main Menu"bodyBgColor = #000000tableBgColor = #000000rowBgColor = #00ff00[Customer]pageTitle = "Customer Info"[Login]pageTitle = "Login"focus = "username"Intro = """This is a value that spans morethan one line. you must encloseit in triple quotes."""# hidden section[.Database]host=my.example.comdb=ADDRESSBOOKuser=php-userpass=foobar```Values of [config file variables](./language-variables/language-config-variables.md) can be inquotes, but not necessary. You can use either single or double quotes.If you have a value that spans more than one line, enclose the entirevalue with triple quotes \("""\). You can put comments into configfiles by any syntax that is not a valid config file syntax. We recommendusing a `#` (hash) at the beginning of the line.The example config file above has two sections. Section names areenclosed in \[brackets\]. Section names can be arbitrary strings notcontaining `[` or `]` symbols. The four variables at the top are globalvariables, or variables not within a section. These variables are alwaysloaded from the config file. If a particular section is loaded, then theglobal variables and the variables from that section are also loaded. Ifa variable exists both as a global and in a section, the sectionvariable is used. If you name two variables the same within a section,the last one will be used unless[`$config_overwrite`](../programmers/api-variables/variable-config-overwrite.md) is disabled.Config files are loaded into templates with the built-in templatefunction [`{config_load}`](./language-builtin-functions/language-function-config-load.md) or the API[`configLoad()`](../programmers/api-functions/api-config-load.md) function.You can hide variables or entire sections by prepending the variablename or section name with a period(.) eg `[.hidden]`. This is useful ifyour application reads the config files and gets sensitive data fromthem that the template engine does not need. If you have third partiesdoing template editing, you can be certain that they cannot readsensitive data from the config file by loading it into the template.Config files (or resources) are loaded by the same resource facilitiesas templates. That means that a config file can also be loaded from a db`$smarty->configLoad("db:my.conf")`.See also [`{config_load}`](./language-builtin-functions/language-function-config-load.md),[`$config_overwrite`](../programmers/api-variables/variable-config-overwrite.md),[`$default_config_handler_func`](../programmers/api-variables/variable-default-config-handler-func.md),[`getConfigVars()`](../programmers/api-functions/api-get-config-vars.md),[`clearConfig()`](../programmers/api-functions/api-clear-config.md) and[`configLoad()`](../programmers/api-functions/api-config-load.md)