{config_load}
{config_load} dipakai untuk mengambil
#variables#
konfig dari file konfigurasi ke dalam
template.
Teladan 7-3. {config_load}
File example.conf.
#ini komentar file config
# variabel global
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00
#seksi variabel kustomer
[Customer]
pageTitle = "Customer Info" |
dan template {config_load file="example.conf"}
<html>
<title>{#pageTitle#|default:"No title"}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html> |
|
File Config
dapat juga berisi seksi. Anda bisa mengambil variabel dari dalam seksi
dengan menambahkan atribut section. Catatan bahwa
variabel config global selalu diambil bersamaan dengan variabel seksi,
dan variabel seksi bernama-sama menimpa global.
Catatan:
Seksi file config dan fungsi template built-in
memanggil {section}
tidak ada kaitannya dengan yang lain, itu terjadi untuk berbagi konvensi
penamaan umum.
Teladan 7-4. function {config_load} dengan seksi {config_load file='example.conf' section='Customer'}
<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html> |
|
Lihat $config_overwrite
untuk membuat arrays dari variabel file config.
Lihat juga halaman config files, halaman
config variables,
$config_dir,
get_config_vars()
dan
config_load().