Files
smarty/docs/fr/designers/language-variables/language-config-variables.xml
2006-10-03 20:48:58 +00:00

122 lines
3.0 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1.6 Maintainer: yannick Status: ready -->
<sect1 id="language.config.variables">
<title>Variables chargées depuis des fichiers de configuration</title>
<para>
Les variables récupérées depuis un
<link linkend="config.files">fichier de configuration</link> sont utilisées
entourées du symbole dièse (#), ou via la variable spéciale smarty
<link linkend="language.variables.smarty.config"><parameter>$smarty.config</parameter></link>.
La dernière synthaxe est utile pour mettre entre guillemets les valeurs des attributs.
</para>
<example>
<title>variables de fichiers de configuration</title>
<para>
Exemple de fichier de configuration - <filename>foo.conf</filename> :
</para>
<programlisting>
<![CDATA[
pageTitle = "C'est le mien"
bodyBgColor = '#eeeeee'
tableBorderSize = 3
tableBgColor = '#bbbbbb'
rowBgColor = '#cccccc'
]]>
</programlisting>
<para>
Exemple de template :
</para>
<programlisting>
<![CDATA[
{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>
]]>
</programlisting>
<para>
Un template démontrant la méthode
<link linkend="language.variables.smarty.config">
<parameter>$smarty.config</parameter></link> :
</para>
<programlisting>
<![CDATA[
{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>
]]>
</programlisting>
<para>
Les deux exemples ci-dessus afficheront :
</para>
<screen>
<![CDATA[
<html>
<title>C'est le mien</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>
]]>
</screen>
</example>
<para>
Les variables de fichier de configuration ne peuvent être utilisés tant
qu'elles n'ont pas été chargées. Cette procédure est expliquée
plus loin dans le document, voir <link
linkend="api.config.load"><varname>{config_load}</varname></link>.
</para>
<para>
Voir aussi
les <link linkend="language.syntax.variables">variables</link> et
les <link linkend="language.variables.smarty">variables réservées $smarty</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->