mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-01 12:51:38 +01:00
186 lines
5.2 KiB
XML
186 lines
5.2 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.12 Maintainer: gerald Status: ready -->
|
|
|
|
<sect1 id="language.function.config.load">
|
|
<title>{config_load}</title>
|
|
|
|
<para>
|
|
<varname>{config_load}</varname> est utiliseé pour charger des variables
|
|
<link linkend="language.config.variables"><parameter>#variables#</parameter></link>
|
|
depuis un <link linkend="config.files">fichier de configuration</link>
|
|
dans un template.
|
|
</para>
|
|
|
|
<informaltable frame="all">
|
|
<tgroup cols="5">
|
|
<colspec colname="param" align="center" />
|
|
<colspec colname="type" align="center" />
|
|
<colspec colname="required" align="center" />
|
|
<colspec colname="default" align="center" />
|
|
<colspec colname="desc" />
|
|
<thead>
|
|
<row>
|
|
<entry>Nom attribut</entry>
|
|
<entry>Type</entry>
|
|
<entry>Requis</entry>
|
|
<entry>Défaut</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>file</entry>
|
|
<entry>chaîne de caractère</entry>
|
|
<entry>Oui</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>Le nom du fichier de configuration à inclure</entry>
|
|
</row>
|
|
<row>
|
|
<entry>section</entry>
|
|
<entry>chaîne de caractère</entry>
|
|
<entry>Non</entry>
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
<entry>Le nom de la section à charger</entry>
|
|
</row>
|
|
<row>
|
|
<entry>scope</entry>
|
|
<entry>chaîne de caractère</entry>
|
|
<entry>non</entry>
|
|
<entry><emphasis>local</emphasis></entry>
|
|
<entry>
|
|
La façon dont la portée des variables est définie, soit
|
|
local, parent ou global. local signifie que la variable est
|
|
chargée dans le contexte du template. parent indique que
|
|
la variable est disponible tant dans le template qui
|
|
l'a inclus que dans le template parent, ayant réalisé
|
|
l'inclusion du sous template. global signifie que la variable
|
|
est diponible dans tous les templates.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>global</entry>
|
|
<entry>booléen</entry>
|
|
<entry>Non</entry>
|
|
<entry><emphasis>No</emphasis></entry>
|
|
<entry>
|
|
Si oui ou non les variables sont disponibles pour les
|
|
templates parents, identique à scope=parent.
|
|
Note: Cet attribut est obsolète depuis l'apparition
|
|
de l'attribut scope, il est toutefois toujours supporté.
|
|
Si scope est défini, global est ignoré.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
<example>
|
|
<title>Fonction {config_load}</title>
|
|
<para>
|
|
Le fichier <filename>example.conf</filename>
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
#ceci est un commentaire de fichier de configuration
|
|
|
|
#variables globales
|
|
pageTitle = "Menu principal"
|
|
bodyBgColor = #000000
|
|
tableBgColor = #000000
|
|
rowBgColor = #00ff00
|
|
|
|
#section de variables personnalisées
|
|
[Customer]
|
|
pageTitle = "Info personnalisée"
|
|
]]>
|
|
</programlisting>
|
|
<para>et le template</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{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>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<para>
|
|
Les <link linkend="config.files">fichiers de configuration</link> peuvent contenir des sections.
|
|
Vous pouvez charger des variables d'une section donnée avec le
|
|
nouvel attribut <parameter>section</parameter>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Les <emphasis>sections</emphasis> des fichiers de configuration
|
|
et la fonction native
|
|
<link linkend="language.function.section"><varname>{section}</varname></link>
|
|
n'ont rien en commun, il s'avère simplement qu'elles portent le même nom.
|
|
</para>
|
|
</note>
|
|
<example>
|
|
<title>fonction {config_load} avec section</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{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>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<para>
|
|
Voir aussi <link linkend="variable.config.overwrite"><parameter>$config_overwrite</parameter></link>
|
|
pour les tableaux de variables de configuration.
|
|
</para>
|
|
|
|
<para>
|
|
Voir aussi
|
|
les <link linkend="config.files">fichiers de configuration</link>,
|
|
les <link linkend="language.config.variables">variables de configuration</link>,
|
|
<link linkend="variable.config.dir"><parameter>$config_dir</parameter></link>,
|
|
<link linkend="api.get.config.vars"><varname>get_config_vars()</varname></link> et
|
|
<link linkend="api.config.load"><varname>config_load()</varname></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
|
|
--> |