Variables cargadas desde archivos de configuración
Las variables que son cargadas de
archivos de configuración son
referenciadas incluyendo entre ellas el signo(#), o como variables
de Smarty
$smarty.config.
La segunda sintaxis es util para incrustar valores de un atributo
dentro de comillas.
Ejemplo 4-5. Variables de configuración
foo.conf:
pageTitle = "This is mine"
bodyBgColor = "#eeeeee"
tableBorderSize = "3"
tableBgColor = "#bbbbbb"
rowBgColor = "#cccccc" |
index.tpl:
{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> |
index.tpl: (sintaxis alternativa)
{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> |
esta es la salida de ambos ejemplos:
<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> |
|
Las variables de un archivo de configuración no pueden ser
usadas hasta después de que son cargadas por los archivos de
configuración.
Este procedimento es explicado posteriormente en este documento en
{config_load}.
Ver también Variables y
$smarty reserved variables