Variabel yang diambil dari file config
Variabel yang diambil dari file config
direferensi dengan menutupinya dalam #tanda kris#,
atau dengan variabel smarty
$smarty.config.
Sintaks terakhir berguna untuk menyertakan ke dalam nilai atribut bertanda
kutip.
Teladan 4-6. variabel config
Contoh file config - foo.conf:
pageTitle = "This is mine"
bodyBgColor = '#eeeeee'
tableBorderSize = 3
tableBgColor = "#bbbbbb"
rowBgColor = "#cccccc" |
Template yang memperlihatkan metode #hash#:
{config_load file='foo.conf'}
<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> |
Template yang memperlihatkan metode
$smarty.config:
{config_load file='foo.conf'}
<html>
<title>{$smarty.config.pageTitle}</title>
<body bgcolor="{$smarty.config.bodyBgColor}">
<table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}">
<tr bgcolor="{$smarty.config.rowBgColor}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html> |
Kedua contoh akan menampilkan:
<html>
<title>This is mine</title>
<body bgcolor="#eeeeee">
<table border="3" bgcolor="#bbbbbb">
<tr bgcolor="#cccccc">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html> |
|
Variabel file config tidak bisa dipakai sampai setelah diambil dari file
config. Prosedur ini dijelaskan nanti dalam dokumen ini di bawah
{config_load}.
Lihat juga variabel dan
variabel terpakai $smarty