Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

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