2004-03-28 15:18:13 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
|
|
|
|
|
<chapter id="api.functions">
|
2004-03-29 10:26:13 +00:00
|
|
|
|
<title>M<EFBFBD>thodes</title>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<sect1 id="api.append">
|
|
|
|
|
|
<title>append</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>append</function></funcdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>append</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>append</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
<paramdef>boolean <parameter>merge</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 10:26:13 +00:00
|
|
|
|
Utilis<69>e pour ajouter un <20>l<EFBFBD>ment a un tableau assign<67>. Si vous utilisez
|
|
|
|
|
|
cette fonction avec une cha<68>ne de caract<63>res, elle est convertie en
|
|
|
|
|
|
tableau auquel on ajoute ensuite l'<27>l<EFBFBD>ment. Vous pouvez explicitement passer
|
2004-03-29 01:40:48 +00:00
|
|
|
|
des paires nom/valeur. Si vous passez le troisi<73>me param<61>tre
|
|
|
|
|
|
(optionel) a vrai, la valeur sera fusionn<6E>e avec le tableau plut(t que
|
2004-03-29 10:18:34 +00:00
|
|
|
|
d'<27>tre ajout<75>e.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Note technique</title>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Le param<61>tre de fusion respecte les cl<63>s des tableaux, ainsi si vous
|
2004-03-29 10:26:13 +00:00
|
|
|
|
fusionnez deux tableaux index<65>s num<75>riquement, ils pourront s'<27>craser
|
2004-03-29 01:40:48 +00:00
|
|
|
|
l'un l'autre ou donner des cl<63>s qui ne se suivent pas. Cela diff<66>re
|
|
|
|
|
|
donc de la fonction PHP array_merge() qui supprime les cl<63>s num<75>riques
|
|
|
|
|
|
et les renum<75>rote.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>append</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// passe des paires nom/valeur
|
|
|
|
|
|
$smarty->append("Name","Fred");
|
|
|
|
|
|
$smarty->append("Address",$address);
|
|
|
|
|
|
|
|
|
|
|
|
// passe un tableau associatif
|
|
|
|
|
|
$smarty->append(array("city" => "Lincoln","state" => "Nebraska"));</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.append.by.ref">
|
|
|
|
|
|
<title>append_by_ref</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>append_by_ref</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>append_by_ref</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
<paramdef>boolean <parameter>merge</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour ajouter des valeurs a un template par r<>f<EFBFBD>rence plut(t que
|
|
|
|
|
|
par copie. Si vous ajoutez une variable par r<>f<EFBFBD>rence puis changez sa
|
|
|
|
|
|
valeur, le changement est aussi r<>percut<75> sur la valeur assign<67>e.
|
|
|
|
|
|
Pour les objets, append_by_ref ne fait pas de copie en m<>moire de l'objet
|
|
|
|
|
|
assign<67>. Voir la documentation PHP pour plus d'informations sur les
|
|
|
|
|
|
r<>f<EFBFBD>rences de variable.
|
|
|
|
|
|
Si vous passez le troisi<73>me param<61>tre a vrai, la valeur sera fusionn<6E>e
|
2004-03-29 10:18:34 +00:00
|
|
|
|
avec le tableau courant plut(t que d'<27>tre ajout<75>e.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Note technique</title>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Le param<61>tre de fusion respecte les cl<63>s des tableaux, ainsi si vous
|
2004-03-29 10:26:13 +00:00
|
|
|
|
fusionnez deux tableaux index<65>s num<75>riquement, ils pourront s'<27>craser
|
2004-03-29 01:40:48 +00:00
|
|
|
|
l'un l'autre ou donner des cl<63>s qui ne se suivent pas. Cela diff<66>re
|
|
|
|
|
|
donc de la fonction PHP array_merge() qui supprime les cl<63>s num<75>riques
|
|
|
|
|
|
et les renum<75>rote.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>append_by_ref</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// ajoute des paires nom/valeur
|
|
|
|
|
|
$smarty->append_by_ref("Name",$myname);
|
|
|
|
|
|
$smarty->append_by_ref("Address",$address);</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.assign">
|
|
|
|
|
|
<title>assign</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>assign</function></funcdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>assign</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour assigner des valeurs aux templates. Vous pouvez
|
2004-03-28 15:18:13 +00:00
|
|
|
|
explicitement passer des paires nom/valeur, ou des tableaux
|
|
|
|
|
|
associatifs contenant des paires nom/valeur.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>assign</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// passe des paires nom/valeur
|
|
|
|
|
|
$smarty->assign("Name","Fred");
|
|
|
|
|
|
$smarty->assign("Address",$address);
|
|
|
|
|
|
|
|
|
|
|
|
// passe un tableau associatif
|
|
|
|
|
|
$smarty->assign(array("city" => "Lincoln","state" => "Nebraska"));</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.assign.by.ref">
|
|
|
|
|
|
<title>assign_by_ref</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>assign_by_ref</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>varname</parameter></paramdef>
|
|
|
|
|
|
<paramdef>mixed <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour assigner des valeurs aux templates par r<>f<EFBFBD>rence plut(t
|
2004-03-29 10:26:13 +00:00
|
|
|
|
que par copie. R<>f<EFBFBD>rez-vous au manuel PHP pour une explication plus pr<70>cise
|
2004-03-29 01:40:48 +00:00
|
|
|
|
sur les r<>f<EFBFBD>rences des variables.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Note technique</title>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Si vous assignez une variable par r<>f<EFBFBD>rence puis changez sa
|
|
|
|
|
|
valeur, le changement est aussi r<>percut<75> sur la valeur assign<67>e.
|
|
|
|
|
|
Pour les objets, assign_by_ref ne fait pas de copie en m<>moire de l'objet
|
2004-03-29 10:26:13 +00:00
|
|
|
|
assign<67>. R<>f<EFBFBD>rez-vous au manuel PHP pour une explication plus pr<70>cise sur
|
2004-03-29 01:40:48 +00:00
|
|
|
|
les r<>f<EFBFBD>rences de variable.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>assign_by_ref</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// passe des paires noms/valeurs
|
|
|
|
|
|
$smarty->assign_by_ref("Name",$myname);
|
|
|
|
|
|
$smarty->assign_by_ref("Address",$address);</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.all.assign">
|
|
|
|
|
|
<title>clear_all_assign</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>clear_all_assign</function></funcdef>
|
|
|
|
|
|
<paramdef><parameter></parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour effacer les valeurs de toutes les variables assign<67>es.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_all_assign</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// efface toutes les variables assign<67>es
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->clear_all_assign();</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.all.cache">
|
|
|
|
|
|
<title>clear_all_cache</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>clear_all_cache</function></funcdef>
|
|
|
|
|
|
<paramdef>int <parameter>expire time</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour effacer les fichiers de cache des templates. Vous pouvez passer un
|
|
|
|
|
|
param<61>tre optionnel afin d'indiquer l'Gge minimun que doivent avoir
|
|
|
|
|
|
les fichiers de cache pour qu'ils soient effac<61>s.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_all_cache</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// efface le cache
|
|
|
|
|
|
$smarty->clear_all_cache();</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.assign">
|
|
|
|
|
|
<title>clear_assign</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>clear_assign</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>var</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Efface la valeur d'une variable assign<67>e. Il peut s'agir
|
2004-03-28 15:18:13 +00:00
|
|
|
|
d'une simple valeur ou d'un tableau de valeur.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_assign</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// efface une variable
|
|
|
|
|
|
$smarty->clear_assign("Name");
|
|
|
|
|
|
|
|
|
|
|
|
// efface plusieurs variables
|
|
|
|
|
|
$smarty->clear_assign(array("Name","Address","Zip"));</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.cache">
|
|
|
|
|
|
<title>clear_cache</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>void</type><methodname>clear_cache</methodname>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>template</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>cache id</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>compile id</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>expire time</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour nettoyer le(s) fichier(s) de cache d'un template en particulier.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
Si vous avez plusieurs fichiers de cache pour ce template vous
|
2004-03-29 01:40:48 +00:00
|
|
|
|
pouvez en sp<73>cifier un en particulier en passant son identifiant
|
|
|
|
|
|
en deuxi<78>me param<61>tre. Vous pouvez aussi passer un identifiant
|
|
|
|
|
|
de compilation en troisi<73>me param<61>tre. Vous pouvez grouper des
|
2004-03-29 10:18:34 +00:00
|
|
|
|
templates ensemble afin qu'ils puissent <20>tre supprim<69>s en groupe.
|
2004-03-29 10:26:13 +00:00
|
|
|
|
R<>f<EFBFBD>rez-vous a la section sur le
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<link linkend="caching">cache</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
pour plus d'informations. Vous pouvez passer un quatri<72>me param<61>tre
|
2004-03-28 15:18:13 +00:00
|
|
|
|
pour indiquer un Gge minimum en secondes que le fichier en cache doit
|
2004-03-29 10:18:34 +00:00
|
|
|
|
avoir avant d'<27>tre effac<61>.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_cache</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// efface le fichier de cache de ce template
|
|
|
|
|
|
$smarty->clear_cache("index.tpl");
|
|
|
|
|
|
|
|
|
|
|
|
// efface un fichier de cache grGce a son identifiant de cache
|
|
|
|
|
|
$smarty->clear_cache("index.tpl","CACHEID");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.compiled.tpl">
|
|
|
|
|
|
<title>clear_compiled_tpl</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>clear_compiled_tpl</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>tpl_file</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour effacer la version compil<69>e du template sp<73>cifi<66> ou
|
|
|
|
|
|
de tous les templates si aucun n'est sp<73>cifi<66>. Cette fonction
|
|
|
|
|
|
est destin<69>e a un usage avanc<6E> et n'est pas habituellement utilis<69>e.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_compiled_tpl</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// efface la version compil<69>e du template sp<73>cifi<66>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->clear_compiled_tpl("index.tpl");
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// efface tout le contenu du r<>pertoire des templates compil<69>s
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->clear_compiled_tpl();</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.clear.config">
|
|
|
|
|
|
<title>clear_config</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>void</type><methodname>clear_config</methodname>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>var</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 10:26:13 +00:00
|
|
|
|
Utilis<69>e pour effacer toutes les variables de configuration s'<27>tant
|
2004-03-29 01:40:48 +00:00
|
|
|
|
vues assigner une valeur. Si une variable est sp<73>cifi<66>e, seule cette
|
|
|
|
|
|
variable est effac<61>e.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>clear_config</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// efface toutes les variables de configuration assign<67>es
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->clear_config();
|
|
|
|
|
|
|
|
|
|
|
|
// efface une seule variable
|
|
|
|
|
|
$smarty->clear_config('foobar');</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.config.load">
|
|
|
|
|
|
<title>config_load</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>void</type><methodname>config_load</methodname>
|
|
|
|
|
|
<methodparam><type>string</type><parameter>file</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>section</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour charger des donn<6E>es d'un fichier de config et les
|
2004-03-28 15:18:13 +00:00
|
|
|
|
assigner a un template. Cette fonction fonctionne exactement comme
|
|
|
|
|
|
la fonction de template <link
|
|
|
|
|
|
linkend="language.function.config.load">config_load</link>.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Note technique</title>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Comme pour Smarty 2.4.0, les variables de templates assign<67>es
|
|
|
|
|
|
sont conserv<72>es entre chaque appel a fetch et display.
|
|
|
|
|
|
Les variables de configuration charg<72>es avec config_load sont
|
|
|
|
|
|
globales. Les fichiers de config sont aussi compil<69>s pour une
|
|
|
|
|
|
ex<65>cution plus rapide et respecte les r<>glages de <link
|
2004-03-28 15:18:13 +00:00
|
|
|
|
linkend="variable.force.compile">force_compile</link> et de <link
|
|
|
|
|
|
linkend="variable.compile.check">compile_check</link>.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>config_load</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// charge les variables de configuration et les assigne
|
|
|
|
|
|
$smarty->config_load('my.conf');
|
|
|
|
|
|
|
|
|
|
|
|
// charge une section
|
|
|
|
|
|
$smarty->config_load('my.conf','foobar');</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.display">
|
|
|
|
|
|
<title>display</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>void</type><methodname>display</methodname>
|
|
|
|
|
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour afficher un template. Il faut fournir un type et un
|
2004-03-28 15:18:13 +00:00
|
|
|
|
chemin de <link
|
|
|
|
|
|
linkend="template.resources">ressource template</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
valides. Vous pouvez passer en second param<61>tre un identifiant
|
2004-03-28 15:18:13 +00:00
|
|
|
|
de fichier de cache. Reportez-vous a la section
|
|
|
|
|
|
<link linkend="caching">cache</link> pour plus de renseignements.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Le troisi<73>me param<61>tre optionnel est un identifiant de compilation.
|
|
|
|
|
|
Cela s'av<61>re utile quand vous voulez compiler diff<66>rentes versions
|
|
|
|
|
|
d'un m<>me template, pour par exemple avoir des templates
|
|
|
|
|
|
compil<69>s s<>par<61>s pour diff<66>rents langages. Une autre utilit<69> de ce
|
|
|
|
|
|
param<61>tre est le cas o<> vous utilisez plus d'un $template_dir mais un seul
|
2004-03-29 10:26:13 +00:00
|
|
|
|
$compile_dir, car certains templates avec le m<>me nom s'<27>craseraient
|
2004-03-29 01:40:48 +00:00
|
|
|
|
entre eux. Vous pouvez aussi r<>gler la variable <link
|
2004-03-28 15:18:13 +00:00
|
|
|
|
linkend="variable.compile.id">$compile_id</link> une seule
|
|
|
|
|
|
fois au lieu de la passer a chaque appel.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>affichage</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
include("Smarty.class.php");
|
|
|
|
|
|
$smarty = new Smarty;
|
|
|
|
|
|
$smarty->caching = true;
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// ne fait un appel a la base de donn<6E>es que si le fichier
|
2004-03-28 15:18:13 +00:00
|
|
|
|
// de cache n'existe pas
|
|
|
|
|
|
if(!$smarty->is_cached("index.tpl"))
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// quelques donn<6E>es
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$address = "245 N 50th";
|
|
|
|
|
|
$db_data = array(
|
|
|
|
|
|
"City" => "Lincoln",
|
|
|
|
|
|
"State" => "Nebraska",
|
|
|
|
|
|
"Zip" = > "68502"
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->assign("Name","Fred");
|
|
|
|
|
|
$smarty->assign("Address",$address);
|
|
|
|
|
|
$smarty->assign($db_data);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// display the output
|
|
|
|
|
|
$smarty->display("index.tpl");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Utilisez la syntaxe des <link
|
|
|
|
|
|
linkend="template.resources">ressources templates</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
pour afficher des fichiers en-dehors du r<>pertoire
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$template_dir
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>exemples de fonction d'affichage de ressources templates</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// chemin absolu
|
|
|
|
|
|
$smarty->display("/usr/local/include/templates/header.tpl");
|
|
|
|
|
|
|
|
|
|
|
|
// chemin absolu (pareil)
|
|
|
|
|
|
$smarty->display("file:/usr/local/include/templates/header.tpl");
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// chemin absolu Windows (on DOIT utiliser le pr<70>fixe "file:")
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->display("file:C:/www/pub/templates/header.tpl");
|
|
|
|
|
|
|
|
|
|
|
|
// inclue a partir de la ressource template "db"
|
|
|
|
|
|
$smarty->display("db:header.tpl");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.fetch">
|
|
|
|
|
|
<title>fetch</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>string</type><methodname>fetch</methodname>
|
|
|
|
|
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour renvoyer le r<>sultat du template plut(t que de l'afficher.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
Il faut passer un type et un chemin de <link
|
|
|
|
|
|
linkend="template.resources">ressource template</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
valides. Vous pouvez passer un identifiant de cache en deuxi<78>me
|
|
|
|
|
|
param<61>tre. Reportez-vous a la section <link linkend="caching">cache
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</link> pour plus de renseignements.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Un troisi<73>me param<61>tre optionnel est un identifiant de compilation.
|
|
|
|
|
|
Cela s'av<61>re utile quand vous voulez compiler diff<66>rentes versions
|
|
|
|
|
|
d'un m<>me template, pour par exemple avoir des templates
|
|
|
|
|
|
compil<69>s s<>par<61>s pour diff<66>rents langages. Une autre utilit<69> de ce
|
|
|
|
|
|
param<61>tre est le cas o<> vous utilisez plus d'un $template_dir
|
|
|
|
|
|
mais un seul $compile_dir, car certains templates avec le m<>me nom
|
2004-03-29 10:26:13 +00:00
|
|
|
|
s'<27>craseraient entre eux. Vous pouvez aussi r<>gler la variable <link
|
2004-03-28 15:18:13 +00:00
|
|
|
|
linkend="variable.compile.id">$compile_id</link> une seule
|
|
|
|
|
|
fois plut(t que de la passer a chaque appel.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>fetch</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
include("Smarty.class.php");
|
|
|
|
|
|
$smarty = new Smarty;
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->caching = true;
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// ne fait un appel a la base de donn<6E>es que si le fichier
|
2004-03-28 15:18:13 +00:00
|
|
|
|
// de cache n'existe pas
|
|
|
|
|
|
if(!$smarty->is_cached("index.tpl"))
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// quelques donn<6E>es
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$address = "245 N 50th";
|
|
|
|
|
|
$db_data = array(
|
|
|
|
|
|
"City" => "Lincoln",
|
|
|
|
|
|
"State" => "Nebraska",
|
|
|
|
|
|
"Zip" = > "68502"
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->assign("Name","Fred");
|
|
|
|
|
|
$smarty->assign("Address",$address);
|
|
|
|
|
|
$smarty->assign($db_data);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re le r<>sultat
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$output = $smarty->fetch("index.tpl");
|
|
|
|
|
|
|
|
|
|
|
|
// fait quelque chose avec $output
|
|
|
|
|
|
|
|
|
|
|
|
echo $output;</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.get.config.vars">
|
|
|
|
|
|
<title>get_config_vars</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>array</type><methodname>get_config_vars</methodname>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Retourne la valeur de la variable de configuration pass<73>e en param<61>tre.
|
|
|
|
|
|
Si aucun param<61>tre n'est donn<6E>, un tableau de toutes les variables de
|
|
|
|
|
|
configuration charg<72>es est renvoy<6F>.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>get_config_vars</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re la variable de configuration charg<72>e 'foo'
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$foo = $smarty->get_config_vars('foo');
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re toutes les variables de configuration charg<72>es
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$config_vars = $smarty->get_config_vars();
|
|
|
|
|
|
|
2004-03-29 10:26:13 +00:00
|
|
|
|
// les affiche a l'<27>cran
|
2004-03-28 15:18:13 +00:00
|
|
|
|
print_r($config_vars);</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.get.registered.object">
|
|
|
|
|
|
<title>get_registered_object</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>array <function>get_registered_object</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>object_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Retourne la r<>f<EFBFBD>rence d'un objet enregistr<74>. Utile quand vous
|
|
|
|
|
|
voulez acc<63>der directement a un objet enregistr<74> avec une
|
2004-03-28 15:18:13 +00:00
|
|
|
|
fonction utilisateur.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>get_registered_object</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
function smarty_block_foo($params, &$smarty) {
|
|
|
|
|
|
if (isset[$params['object']]) {
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re la r<>f<EFBFBD>rence de l'objet enregistr<74>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$obj_ref =& $smarty->get_registered_object($params['object']);
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// $obj_ref est maintenant une r<>f<EFBFBD>rence vers l'objet
|
2004-03-28 15:18:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
}</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.get.template.vars">
|
|
|
|
|
|
<title>get_template_vars</title>
|
2004-03-28 15:39:32 +00:00
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>array</type><methodname>get_template_vars</methodname>
|
|
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
2004-03-28 15:18:13 +00:00
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Retourne la valeur assign<67>e pass<73>e en param<61>tre. Si aucun param<61>tre
|
|
|
|
|
|
n'est donn<6E>, un tableau de toutes les variables assign<67>es est
|
|
|
|
|
|
renvoy<6F>.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>get_template_vars</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re la variable 'foo' assign<67>e au template
|
2004-03-28 15:18:13 +00:00
|
|
|
|
// get assigned template var 'foo'
|
|
|
|
|
|
$foo = $smarty->get_template_vars('foo');
|
|
|
|
|
|
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// r<>cup<75>re toutes les variables assign<67>es a ce template
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$tpl_vars = $smarty->get_template_vars();
|
|
|
|
|
|
|
2004-03-29 10:26:13 +00:00
|
|
|
|
// les affiche a l'<27>cran
|
2004-03-28 15:18:13 +00:00
|
|
|
|
print_r($tpl_vars);</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.is.cached">
|
|
|
|
|
|
<title>is_cached</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>is_cached</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>template</parameter></paramdef>
|
|
|
|
|
|
<paramdef>[string <parameter>cache_id</parameter>]</paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Retourne vrai s'il y a un fichier de cache valide pour ce template.
|
|
|
|
|
|
Cela fonctionne seulement si <link
|
|
|
|
|
|
linkend="variable.caching">caching</link> est a vrai.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>is_cached</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->caching = true;
|
|
|
|
|
|
|
|
|
|
|
|
if(!$smarty->is_cached("index.tpl")) {
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// faire des requ<71>tes base de donn<6E>es et assigner
|
2004-03-28 15:18:13 +00:00
|
|
|
|
// des variables ici.
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->display("index.tpl");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Vous pouvez aussi passer en second param<61>tre un identifiant
|
2004-03-28 15:18:13 +00:00
|
|
|
|
de cache au cas o<> vous voudriez plusieurs fichiers de cache
|
|
|
|
|
|
pour ce template.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>is_cached with multiple-cache template</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->caching = true;
|
|
|
|
|
|
|
|
|
|
|
|
if(!$smarty->is_cached("index.tpl","FrontPage")) {
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// faire des requ<71>tes base de donn<6E>es et assigner
|
2004-03-28 15:18:13 +00:00
|
|
|
|
// des variables ici.
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->display("index.tpl","FrontPage");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.load.filter">
|
|
|
|
|
|
<title>load_filter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>load_filter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>type</parameter></paramdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 10:18:34 +00:00
|
|
|
|
Cette fonction peut <20>tre utilis<69>e pour charger un plugin
|
2004-03-29 01:40:48 +00:00
|
|
|
|
de filtrage. Le premier argument sp<73>cifie le type du filtre
|
2004-03-28 15:18:13 +00:00
|
|
|
|
et peut prendre l'une des valeurs suivantes : 'pre', 'post'
|
2004-03-29 01:40:48 +00:00
|
|
|
|
ou 'output'. Le second argument sp<73>cifie le nom du plugin
|
2004-03-28 15:18:13 +00:00
|
|
|
|
de filtrage, par exemple 'trim'.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>Chargement de plugins de filtrage</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->load_filter('pre', 'trim'); // charge le filtre 'trim' de type 'pre'
|
2004-03-29 01:40:48 +00:00
|
|
|
|
$smarty->load_filter('pre', 'datefooter'); // charge un autre filtre de type 'pre' appel<65> 'datefooter'
|
2004-03-28 15:18:13 +00:00
|
|
|
|
$smarty->load_filter('output', 'compress'); // charge le filtre 'compress' de type 'output'</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.block">
|
|
|
|
|
|
<title>register_block</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_block</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>string <parameter>impl</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarrer dynamiquement des plugins de fonction
|
|
|
|
|
|
de blocs. Il faut passer en param<61>tre le nom de la fonction
|
|
|
|
|
|
de blocs, suivi du nom de la fonction PHP qui l'impl<70>mente.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>register_block</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
/* PHP */
|
|
|
|
|
|
$smarty->register_block("translate", "do_translation");
|
|
|
|
|
|
|
|
|
|
|
|
function do_translation ($params, $content, &$smarty) {
|
|
|
|
|
|
if ($content) {
|
|
|
|
|
|
$lang = $params['lang'];
|
|
|
|
|
|
// fait de la traduction avec la variable $content
|
|
|
|
|
|
echo $translation;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{* template *}
|
|
|
|
|
|
{translate lang="br"}
|
|
|
|
|
|
Hello, world!
|
|
|
|
|
|
{/translate}</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.compiler.function">
|
|
|
|
|
|
<title>register_compiler_function</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_compiler_function</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>string <parameter>impl</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement un plugin de fonction
|
|
|
|
|
|
de compilation. Il faut passer en param<61>tres le nom de la fonction
|
2004-03-28 15:18:13 +00:00
|
|
|
|
de compilation, suivi par la fonction PHP qui
|
2004-03-29 01:40:48 +00:00
|
|
|
|
l'impl<70>mente.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.function">
|
|
|
|
|
|
<title>register_function</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_function</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>string <parameter>impl</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement des plugins de fonction
|
|
|
|
|
|
de templates. Il faut passer en param<61>tres le nom de la fonction
|
|
|
|
|
|
de templates, suivi par le nom de la fonction PHP qui l'impl<70>mente.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>register_function</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->register_function("date_now", "print_current_date");
|
|
|
|
|
|
|
|
|
|
|
|
function print_current_date ($params) {
|
|
|
|
|
|
extract($params);
|
|
|
|
|
|
if(empty($format))
|
|
|
|
|
|
$format="%b %e, %Y";
|
|
|
|
|
|
echo strftime($format,time());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// vous pouvez maintenant utiliser ceci dans Smarty pour afficher
|
|
|
|
|
|
// la date actuelle : {date_now} ou {date_now format="%Y/%m/%d"}
|
|
|
|
|
|
// pour la formater</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.modifier">
|
|
|
|
|
|
<title>register_modifier</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_modifier</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>string <parameter>impl</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement un plugin de modificateur.
|
|
|
|
|
|
Il faut passer en param<61>tre le nom du modificateur de variables,
|
|
|
|
|
|
suivi de la fonction PHP qui l'impl<70>mente.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>register_modifier</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// associons la fonction PHP stripslashes a un modificateur Smarty.
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->register_modifier("sslash","stripslashes");
|
|
|
|
|
|
|
|
|
|
|
|
// vous pouvez maintenant utiliser {$var|sslash} pour supprimer les slash des variables</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.object">
|
|
|
|
|
|
<title>register_object</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_object</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>object_name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>object <parameter>$object</parameter></paramdef>
|
|
|
|
|
|
<paramdef>array <parameter>allowed methods/properties</parameter></paramdef>
|
|
|
|
|
|
<paramdef>boolean <parameter>format</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour enregistrer un objet a utiliser dans un template.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
Reportez-vous a la section
|
|
|
|
|
|
<link linkend="advanced.features.objects">objet</link> de
|
|
|
|
|
|
ce manuel pour des exemples.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.outputfilter">
|
|
|
|
|
|
<title>register_outputfilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_outputfilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement des filtres de sortie, pour
|
|
|
|
|
|
agir sur la sortie d'un template avant qu'elle ne soit affich<63>e.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
Reportez-vous a la section <link linkend="advanced.features.outputfilters">
|
|
|
|
|
|
filtres de sortie</link> pour plus d'information sur le sujet.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.postfilter">
|
|
|
|
|
|
<title>register_postfilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_postfilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement des filtres de post-compilation pour y faire
|
2004-03-29 10:26:13 +00:00
|
|
|
|
passer des templates une fois qu'ils ont <20>t<EFBFBD> compil<69>s. Reportez-vous
|
2004-03-28 15:18:13 +00:00
|
|
|
|
a la section
|
|
|
|
|
|
<link linkend="advanced.features.postfilters">filtres de post-compilation de templates</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
pour avoir plus de renseignements sur la faton de param<61>trer les fonctions
|
2004-03-28 15:18:13 +00:00
|
|
|
|
de post-compilation.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.prefilter">
|
|
|
|
|
|
<title>register_prefilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_prefilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement des filtres de pr<70>-compilation pour y faire
|
|
|
|
|
|
passer des templates avant qu'ils ne soient compil<69>s. Reportez-vous
|
2004-03-28 15:18:13 +00:00
|
|
|
|
a la section
|
2004-03-29 01:40:48 +00:00
|
|
|
|
<link linkend="advanced.features.postfilters">filtres de pr<70>-compilation de templates</link>
|
|
|
|
|
|
pour avoir plus de renseignements sur la faton de param<61>trer les fonctions
|
|
|
|
|
|
de pr<70>-compilation.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.register.resource">
|
|
|
|
|
|
<title>register_resource</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>register_resource</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
<paramdef>array <parameter>resource_funcs</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement une ressource plugin
|
|
|
|
|
|
dans Smarty. Il faut passer en param<61>tre le nom de la ressource
|
|
|
|
|
|
et le tableau des fonctions PHP qui l'impl<70>mentent. Reportez-vous
|
2004-03-28 15:18:13 +00:00
|
|
|
|
a la section <link linkend="template.resources">ressources templates</link>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
pour avoir plus d'informations sur la faton de param<61>trer une fonction
|
|
|
|
|
|
r<>cup<75>rant des templates.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>register_resource</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->register_resource("db", array("db_get_template",
|
|
|
|
|
|
"db_get_timestamp",
|
|
|
|
|
|
"db_get_secure",
|
|
|
|
|
|
"db_get_trusted"));</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.trigger.error">
|
|
|
|
|
|
<title>trigger_error</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>trigger_error</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>error_msg</parameter></paramdef>
|
|
|
|
|
|
<paramdef>[int <parameter>level</parameter>]</paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 10:18:34 +00:00
|
|
|
|
Cette fonction peut-<2D>tre utilis<69>e pour afficher un message d'erreur
|
2004-03-29 01:40:48 +00:00
|
|
|
|
en utilisant Smarty. Le param<61>tre <parameter>level</parameter>
|
|
|
|
|
|
peut prendre l'une des valeures utilis<69>es par la fonction PHP
|
|
|
|
|
|
trigger_error, i.e. E_USER_NOTICE, E_USER_WARNING, etc. Par d<>faut
|
2004-03-28 15:18:13 +00:00
|
|
|
|
il s'agit de E_USER_WARNING.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
|
|
|
|
<sect1 id="api.template.exists">
|
|
|
|
|
|
<title>template_exists</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>bool <function>template_exists</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>template</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Cette fonction v<>rifie si le template sp<73>cifi<66> existe. Elle accepte
|
2004-03-28 15:18:13 +00:00
|
|
|
|
soit un chemin vers le template, soit une ressource de type
|
2004-03-29 01:40:48 +00:00
|
|
|
|
chaene de caract<63>res pr<70>cisant le nom du template.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.block">
|
|
|
|
|
|
<title>unregister_block</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_block</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un plugin de fonction
|
|
|
|
|
|
de blocs. Passez en param<61>tre le nom du bloc.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.compiler.function">
|
|
|
|
|
|
<title>unregister_compiler_function</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_compiler_function</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un fonction de compilation.
|
|
|
|
|
|
Passez en param<61>tre le nom de la fonction de compilation.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.function">
|
|
|
|
|
|
<title>unregister_function</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_function</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un plugin de fonction
|
|
|
|
|
|
de templates. Passez en param<61>tres le nom de la fonction de templates.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>unregister_function</title>
|
|
|
|
|
|
<programlisting>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
// nous ne voulons pas que les designers de templates aient acc<63>s
|
|
|
|
|
|
// au syst<73>me de fichiers.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
|
|
|
|
|
|
$smarty->unregister_function("fetch");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.modifier">
|
|
|
|
|
|
<title>unregister_modifier</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_modifier</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un plugin modificateur de variable.
|
|
|
|
|
|
Passez en param<61>tre le nom du modificateur de templates.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>unregister_modifier</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
// nous ne voulons pas que les designers de templates
|
2004-03-29 10:26:13 +00:00
|
|
|
|
// suppriment les balises des <20>lements
|
2004-03-28 15:18:13 +00:00
|
|
|
|
|
|
|
|
|
|
$smarty->unregister_modifier("strip_tags");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.object">
|
|
|
|
|
|
<title>unregister_object</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_object</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>object_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer un objet.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.outputfilter">
|
|
|
|
|
|
<title>unregister_outputfilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_outputfilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un filtre de sortie.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.postfilter">
|
|
|
|
|
|
<title>unregister_postfilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_postfilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un filtre de post-compilation.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.prefilter">
|
|
|
|
|
|
<title>unregister_prefilter</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_prefilter</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>function_name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un filtre de pr<70>-compilation.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="api.unregister.resource">
|
|
|
|
|
|
<title>unregister_resource</title>
|
|
|
|
|
|
<funcsynopsis>
|
|
|
|
|
|
<funcprototype>
|
|
|
|
|
|
<funcdef>void <function>unregister_resource</function></funcdef>
|
|
|
|
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
|
|
|
|
</funcprototype>
|
|
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
<para>
|
2004-03-29 01:40:48 +00:00
|
|
|
|
Utilis<69>e pour d<>sallouer dynamiquement un plugin ressource.
|
|
|
|
|
|
Passez en param<61>tre le nom de la ressource.
|
2004-03-28 15:18:13 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>unregister_resource</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
$smarty->unregister_resource("db");</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect1>
|
|
|
|
|
|
</chapter>
|
|
|
|
|
|
<!-- 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
|
2004-03-28 15:39:32 +00:00
|
|
|
|
-->
|