| 148 |
lars |
1 |
Variables loaded from config files {#language.config.variables}
|
|
|
2 |
==================================
|
|
|
3 |
|
|
|
4 |
Variables that are loaded from the [config files](#config.files) are
|
|
|
5 |
referenced by enclosing them within `#hash_marks#`, or with the smarty
|
|
|
6 |
variable [`$smarty.config`](#language.variables.smarty.config). The
|
|
|
7 |
later syntax is useful for embedding into quoted attribute values, or
|
|
|
8 |
accessing variable values such as \$smarty.config.\$foo.
|
|
|
9 |
|
|
|
10 |
Example config file - `foo.conf`:
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
pageTitle = "This is mine"
|
|
|
14 |
bodyBgColor = '#eeeeee'
|
|
|
15 |
tableBorderSize = 3
|
|
|
16 |
tableBgColor = "#bbbbbb"
|
|
|
17 |
rowBgColor = "#cccccc"
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
A template demonstrating the `#hash#` method:
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
{config_load file='foo.conf'}
|
|
|
25 |
<html>
|
|
|
26 |
<title>{#pageTitle#}</title>
|
|
|
27 |
<body bgcolor="{#bodyBgColor#}">
|
|
|
28 |
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
|
|
29 |
<tr bgcolor="{#rowBgColor#}">
|
|
|
30 |
<td>First</td>
|
|
|
31 |
<td>Last</td>
|
|
|
32 |
<td>Address</td>
|
|
|
33 |
</tr>
|
|
|
34 |
</table>
|
|
|
35 |
</body>
|
|
|
36 |
</html>
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
A template demonstrating the
|
|
|
41 |
[`$smarty.config`](#language.variables.smarty.config) method:
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
{config_load file='foo.conf'}
|
|
|
45 |
<html>
|
|
|
46 |
<title>{$smarty.config.pageTitle}</title>
|
|
|
47 |
<body bgcolor="{$smarty.config.bodyBgColor}">
|
|
|
48 |
<table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}">
|
|
|
49 |
<tr bgcolor="{$smarty.config.rowBgColor}">
|
|
|
50 |
<td>First</td>
|
|
|
51 |
<td>Last</td>
|
|
|
52 |
<td>Address</td>
|
|
|
53 |
</tr>
|
|
|
54 |
</table>
|
|
|
55 |
</body>
|
|
|
56 |
</html>
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
Both examples would output:
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
<html>
|
|
|
64 |
<title>This is mine</title>
|
|
|
65 |
<body bgcolor="#eeeeee">
|
|
|
66 |
<table border="3" bgcolor="#bbbbbb">
|
|
|
67 |
<tr bgcolor="#cccccc">
|
|
|
68 |
<td>First</td>
|
|
|
69 |
<td>Last</td>
|
|
|
70 |
<td>Address</td>
|
|
|
71 |
</tr>
|
|
|
72 |
</table>
|
|
|
73 |
</body>
|
|
|
74 |
</html>
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
Config file variables cannot be used until after they are loaded in from
|
|
|
79 |
a config file. This procedure is explained later in this document under
|
|
|
80 |
[`{config_load}`](#language.function.config.load).
|
|
|
81 |
|
|
|
82 |
See also [variables](#language.syntax.variables) and [\$smarty reserved
|
|
|
83 |
variables](#language.variables.smarty)
|