mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
sync with EN
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.7 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.8 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.function.if">
|
||||
<title>{if},{elseif},{else}</title>
|
||||
@@ -16,6 +16,11 @@
|
||||
<emphasis>&&</emphasis>, <emphasis>and</emphasis>,
|
||||
<emphasis>is_array()</emphasis>, etc.
|
||||
</para>
|
||||
<para>
|
||||
Si <link linkend="variable.security">$security</link> est actif,
|
||||
alors le tableau <emphasis>IF_FUNCS</emphasis> dans le tableau
|
||||
<link linkend="variable.security.settings">$security_settings</link> (?!).
|
||||
</para>
|
||||
<para>
|
||||
La liste suivante pr<70>sente les op<6F>rateurs reconnus, qui doivent <20>tre entour<75>s d'espaces.
|
||||
Remarquez que les <20>l<EFBFBD>ments list<73>s entre [crochets] sont optionnels. Les <20>quivalents
|
||||
@@ -162,13 +167,6 @@
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* l'exemple suivant NE fonctionne PAS, les op<6F>rateurs
|
||||
doivent <20>tre entour<75>s d'espaces. *}
|
||||
{if $name=="Fred" || $name=="Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
|
||||
{* les parenth<74>ses sont autoris<69>es *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
...
|
||||
@@ -179,6 +177,16 @@ doivent
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* V<>rifie si c'est un tableau. *}
|
||||
{if is_array($foo) }
|
||||
.....
|
||||
{/if}
|
||||
|
||||
{* V<>rifie si la variable est nulle. *}
|
||||
{if isset($foo) }
|
||||
.....
|
||||
{/if}
|
||||
|
||||
{* teste si les valeurs sont paires(even) ou impaires(odd) *}
|
||||
{if $var is even}
|
||||
...
|
||||
@@ -206,17 +214,6 @@ doivent
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* ------- if avec des fonctions PHP ------- *}
|
||||
{* check for array. *}
|
||||
{if is_array($foo) }
|
||||
.....
|
||||
{/if}
|
||||
|
||||
{* v<>rification du tableau. *}
|
||||
{if isset($foo) }
|
||||
.....
|
||||
{/if}
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.9 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.10 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.function.include">
|
||||
<title>{include}</title>
|
||||
@@ -17,6 +17,13 @@
|
||||
qui d<>finit une variable de template dans laquelle la sortie de
|
||||
{include} sera stock<63>e plut<75>t qu'affich<63>e.
|
||||
</para>
|
||||
<para>
|
||||
Toutes les valeurs des variables assign<67>es sont restaur<75>es lorsque
|
||||
le template inclus est termin<69>. Ceci signifie que vous pouvez utiliser
|
||||
toutes les variables d'un template inclus dans le template qui l'inclut.
|
||||
Mais les modifications des variables dans le template inclus ne sont pas
|
||||
visibles dans le template qui l'inclut apr<70>s l'instruction {include}.
|
||||
</para>
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
|
@@ -1,8 +1,26 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.8 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.14 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.function.section">
|
||||
<title>section, sectionelse</title>
|
||||
<title>{section},{sectionelse}</title>
|
||||
<para>
|
||||
Les balises <emphasis>section</emphasis> sont utilis<69>es pour
|
||||
parcourir un <emphasis role="bold">tableau de donn<6E>es</emphasis>
|
||||
(tout comme <link linkend="language.function.foreach">{foreach}</link>).
|
||||
Toutes les balises <emphasis>{section}</emphasis> doivent <20>tre utilis<69>es
|
||||
de paire avec les balises <emphasis>{/section}</emphasis>. Les param<61>tres
|
||||
requis sont <emphasis>name</emphasis> et <emphasis>loop</emphasis>.
|
||||
Le nom de la {section} est, selon votre choix, compos<6F> de lettres,
|
||||
chiffres et underscores. Les sections peuvent <20>tre imbriqu<71>es,
|
||||
mais leurs noms doivent <20>tre uniques. La variable de parcours
|
||||
(g<>n<EFBFBD>ralement un tableau de donn<6E>es) d<>termine le nombre de fois
|
||||
que la section sera parcourue. Lorsque l'on affiche une variable
|
||||
dans une section, le nom de la section doit pr<70>c<EFBFBD>der
|
||||
la variable entre crochets []. <emphasis>{sectionelse}</emphasis>
|
||||
est ex<65>cut<75> lorsqu'aucune valeur n'est trouv<75>e dans la variable <20>
|
||||
parcourir.
|
||||
</para>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -76,29 +94,30 @@
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Les balises <emphasis>section</emphasis> sont utilis<69>es pour
|
||||
parcourir un tableau de donn<6E>es. Toutes les balises
|
||||
<emphasis>{section}</emphasis> doivent <20>tre utilis<69>es de paire avec
|
||||
les balises <emphasis>{/section}</emphasis>. Les param<61>tres requis
|
||||
sont <emphasis>name</emphasis> et <emphasis>loop</emphasis>.
|
||||
Le nom de la {section} est, selon votre choix, compos<6F> de lettres,
|
||||
chiffres et underscores. Les sections peuvent <20>tre imbriqu<71>es,
|
||||
mais leurs noms doivent <20>tre uniques. La variable de parcours
|
||||
(g<>n<EFBFBD>ralement un tableau de donn<6E>es) d<>termine le nombre de fois
|
||||
que la section sera parcourue. Lorsque l'on affiche une variable
|
||||
dans une section, le nom de la section doit pr<70>c<EFBFBD>der
|
||||
la variable entre crochets. <emphasis>{sectionelse}</emphasis>
|
||||
est ex<65>cut<75> lorsqu'aucune valeur n'est trouv<75>e dans la variable <20>
|
||||
parcourir.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>section</title>
|
||||
<title>{section}</title>
|
||||
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = array(1000,1001,1002);
|
||||
$smarty->assign('custid',$data);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Cet exemple va afficher toutes les valeurs du tableau $idClient *}
|
||||
{section name=client loop=$idClient}
|
||||
id: {$idClient[client]}<br />
|
||||
{* Cet exemple affiche toutes les valeurs du tableau $custid *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
<hr />
|
||||
{* Affiche toutes les valeurs du tableau $custid dans le sens inverse *}
|
||||
{section name=foo loop=$custid step=-1}
|
||||
{$custid[foo]}<br />
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -110,23 +129,69 @@
|
||||
id: 1000<br />
|
||||
id: 1001<br />
|
||||
id: 1002<br />
|
||||
<hr />
|
||||
id: 1002<br />
|
||||
id: 1001<br />
|
||||
id: 1000<br />
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Voici d'autres exemples sans tableaux assign<67>s.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=foo start=10 loop=20 step=2}
|
||||
{$smarty.section.foo.index}
|
||||
{/section}
|
||||
<hr />
|
||||
{section name=bar loop=21 max=6 step=-2}
|
||||
{$smarty.section.bar.index}
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'exemple ci-dessus affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
10 12 14 16 18
|
||||
<hr />
|
||||
20 18 16 14 12 10
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>section, variable de parcours</title>
|
||||
<title>{section}, variable de parcours</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$id = array(1001,1002,1003);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
$fullnames = array('John Smith','Jack Jones','Jane Munson');
|
||||
$smarty->assign('name',$fullnames);
|
||||
|
||||
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
|
||||
$smarty->assign('address',$addr);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* La variable de parcours d<>termine uniquement le nombre de fois que nous allons
|
||||
{*
|
||||
La variable de parcours d<>termine uniquement le nombre de fois que nous allons
|
||||
rentrer dans la boucle. Vous pouvez acc<63>der <20> toutes les variables du template
|
||||
lorsque vous <20>tes dans une section. Cet exemple part du principe que
|
||||
$idClient, $noms et $adresses sont tous des tableaux qui contiennent
|
||||
autant de valeurs les uns que les autres.*}
|
||||
autant de valeurs les uns que les autres.
|
||||
*}
|
||||
{section name=client loop=$idClient}
|
||||
id: {$idClient[client]}<br />
|
||||
nom: {$noms[client]}<br />
|
||||
addresse: {$addresses[client]}<br />
|
||||
id : {$custid[customer]}<br />
|
||||
nom : {$name[customer]}<br />
|
||||
addresse : {$address[customer]}<br />
|
||||
<p>
|
||||
{/section}
|
||||
]]>
|
||||
@@ -136,33 +201,39 @@ id: 1002<br />
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
id: 1000<br />
|
||||
nom: John Smith<br />
|
||||
addresse: 253 N 45th<br />
|
||||
<p>
|
||||
id: 1001<br />
|
||||
nom: Jack Jones<br />
|
||||
addresse: 417 Mulberry ln<br />
|
||||
id : 1000<br />
|
||||
nom : John Smith<br />
|
||||
addresse : 253 N 45th
|
||||
</p>
|
||||
<p>
|
||||
id: 1002<br />
|
||||
nom: Jane Munson<br />
|
||||
addresse: 5605 apple st<br />
|
||||
id : 1001<br />
|
||||
nom : Jack Jones<br />
|
||||
addresse : 417 Mulberry ln
|
||||
</p>
|
||||
<p>
|
||||
id : 1002<br />
|
||||
nom : Jane Munson<br />
|
||||
addresse : 5605 apple st
|
||||
</p>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>nom de section</title>
|
||||
<title>nom de {section}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Le nom de la section peut <20>tre ce que vous voulez,
|
||||
et est utilis<69> pour r<>f<EFBFBD>rencer les donn<6E>es depuis la section. *}
|
||||
{*
|
||||
Le nom de la section peut <20>tre ce que vous voulez,
|
||||
et est utilis<69> pour r<>f<EFBFBD>rencer les donn<6E>es depuis la section.
|
||||
*}
|
||||
{section name=monTableau loop=$idClient}
|
||||
<p>
|
||||
id: {$idCLient[monTableau]}<br />
|
||||
name: {$noms[monTableau]}<br />
|
||||
address: {$addresses[monTableau]}<br />
|
||||
<p>
|
||||
address: {$addresses[monTableau]}
|
||||
</p>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -170,21 +241,53 @@ addresse: 5605 apple st<br />
|
||||
|
||||
<example>
|
||||
<title>sections imbriqu<71>es</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$id = array(1001,1002,1003);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
$fullnames = array('John Smith','Jack Jones','Jane Munson');
|
||||
$smarty->assign('name',$fullnames);
|
||||
|
||||
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
|
||||
$smarty->assign('address',$addr);
|
||||
|
||||
$types = array(
|
||||
array( 'home phone', 'cell phone', 'e-mail'),
|
||||
array( 'home phone', 'web'),
|
||||
array( 'cell phone')
|
||||
);
|
||||
$smarty->assign('contact_type', $types);
|
||||
|
||||
$info = array(
|
||||
array('555-555-5555', '666-555-5555', 'john@myexample.com'),
|
||||
array( '123-456-4', 'www.example.com'),
|
||||
array( '0457878')
|
||||
);
|
||||
$smarty->assign('contact_info', $info);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Les sections peuvent <20>tre imbriqu<71>es <20> un nombre de niveaux illimit<69>.
|
||||
{*
|
||||
Les sections peuvent <20>tre imbriqu<71>es <20> un nombre de niveaux illimit<69>.
|
||||
Gr<47>ce aux sections imbriqu<71>es, vous pouvez acc<63>der <20> des structures de donn<6E>es
|
||||
complexes, comme des tableaux multi-dimentionnels. Dans cet exemple,
|
||||
$type_contact[client] est un tableau de type de contact pour le client
|
||||
courant. *}
|
||||
courant.
|
||||
*}
|
||||
{section name=client loop=$idClient}
|
||||
<hr />
|
||||
id: {$idClient[client]}<br />
|
||||
nom: {$nom[client]}<br />
|
||||
addresse: {$addresse[client]}<br />
|
||||
{section name=contact loop=$type_contact[client]}
|
||||
{$type_contact[client][contact]}: {$info_contact[client][contact]}<br />
|
||||
{/section}
|
||||
<p>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -193,41 +296,63 @@ addresse: 5605 apple st<br />
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<hr />
|
||||
id: 1000<br />
|
||||
nom: John Smith<br />
|
||||
addresse: 253 N 45th<br />
|
||||
telephone: 555-555-5555<br />
|
||||
telephone portable: 555-555-5555<br />
|
||||
e-mail: john@myexample.com<br />
|
||||
<p>
|
||||
<hr />
|
||||
id: 1001<br />
|
||||
nom: Jack Jones<br />
|
||||
addresse: 417 Mulberry ln<br />
|
||||
telephone: 555-555-5555<br />
|
||||
telephone portable: 555-555-5555<br />
|
||||
e-mail: jack@myexample.com<br />
|
||||
<p>
|
||||
<hr />
|
||||
id: 1002<br />
|
||||
nom: Jane Munson<br />
|
||||
addresse: 5605 apple st<br />
|
||||
telephone: 555-555-5555<br />
|
||||
telephone portable: 555-555-5555<br />
|
||||
e-mail: jane@myexample.com<br />
|
||||
<p>
|
||||
<hr />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Sections et tableaux associatifs</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = array(
|
||||
array('name' => 'John Smith', 'home' => '555-555-5555',
|
||||
'cell' => '666-555-5555', 'email' => 'john@myexample.com'),
|
||||
array('name' => 'Jack Jones', 'home' => '777-555-5555',
|
||||
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
|
||||
array('name' => 'Jane Munson', 'home' => '000-555-5555',
|
||||
'cell' => '123456', 'email' => 'jane@myexample.com')
|
||||
);
|
||||
$smarty->assign('contacts',$data);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Exemple d'affichage d'un tableau associatif dans une section *}
|
||||
{*
|
||||
Exemple d'affichage d'un tableau associatif dans une section
|
||||
*}
|
||||
{section name=client loop=$contacts}
|
||||
<p>
|
||||
nom: {$contacts[client].name}<br />
|
||||
telephone: {$contacts[client].home}<br />
|
||||
portable: {$contacts[client].cell}<br />
|
||||
e-mail: {$contacts[client].email}<p>
|
||||
e-mail: {$contacts[client].email}
|
||||
</p>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -236,24 +361,62 @@ e-mail: jane@myexample.com<br />
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<p>
|
||||
nom: John Smith<br />
|
||||
telephone: 555-555-5555<br />
|
||||
portable: 555-555-5555<br />
|
||||
e-mail: john@myexample.com<p>
|
||||
e-mail: john@myexample.com
|
||||
</p>
|
||||
<p>
|
||||
nom: Jack Jones<br />
|
||||
telephone: 555-555-5555<br />
|
||||
portable: 555-555-5555<br />
|
||||
e-mail: jack@myexample.com<p>
|
||||
e-mail: jack@myexample.com
|
||||
</p>
|
||||
<p>
|
||||
nom: Jane Munson<br />
|
||||
telephone: 555-555-5555<br />
|
||||
portable: 555-555-5555<br />
|
||||
e-mail: jane@myexample.com<p>
|
||||
</p>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<para>Exemple avec une base de donn<6E>es (eg. en utilisant Pear ou Adodb)</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$sql = 'select id, name, home, cell, email from contacts';
|
||||
$smarty->assign('contacts',$db->getAll($sql) );
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{*
|
||||
Affiche le r<>sultat de la base de donn<6E>es dans un tableau
|
||||
*}
|
||||
<table>
|
||||
<tr><th> </th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
|
||||
{section name=co loop=$contacts}
|
||||
<tr>
|
||||
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
|
||||
<td>{$contacts[co].name}</td>
|
||||
<td>{$contacts[co].home}</td>
|
||||
<td>{$contacts[co].cell}</td>
|
||||
<td>{$contacts[co].email}</td>
|
||||
<tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<example>
|
||||
<title>sectionelse</title>
|
||||
<title>{sectionelse}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* sectionelse est ex<65>cut<75> s'il n'existe aucune valeur dans idClient *}
|
||||
@@ -271,34 +434,37 @@ e-mail: jane@myexample.com<p>
|
||||
<link linkend="language.variables.smarty.loops">{$smarty.section.sectionname.varname}</link>
|
||||
</para>
|
||||
<para>
|
||||
NOTE: Depuis Smarty 1.5.0, la syntaxe pour les propi<70>t<EFBFBD>s des sections
|
||||
Depuis Smarty 1.5.0, la syntaxe pour les propri<EFBFBD>t<EFBFBD>s des sections
|
||||
a <20>t<EFBFBD> chang<6E>e de {%sectionname.varname%} <20>
|
||||
{$smarty.section.nomSection.nomVariable}. L'ancienne syntaxe est toujours
|
||||
support<72>e, mais vous ne verrez que des exemples avec la nouvelle syntaxe
|
||||
dans le manuel.
|
||||
</para>
|
||||
|
||||
<sect2 id="section.property.index">
|
||||
<title>index</title>
|
||||
<para>
|
||||
Index est utilis<69> pour afficher l'index de parcours courant, commence par
|
||||
0 (ou l'attribut start), et s'incr<63>mente de 1 (ou de la valeur
|
||||
de l'attribut step).
|
||||
0 (ou l'attribut start s'il est fourni), et s'incr<63>mente de 1 (ou de la valeur
|
||||
de l'attribut step s'il est fourni).
|
||||
</para>
|
||||
<note>
|
||||
<title>Note technique</title>
|
||||
<para>
|
||||
Si les attributs step et start ne sont pas modifi<66>s, alors index
|
||||
fonctionne de la m<>me fa<66>on que <link
|
||||
fonctionne de la m<>me fa<66>on que <link
|
||||
linkend="section.property.iteration">iteration</link>, <20> l'exception qu'il commence
|
||||
par 0 plut<75>t que par 1.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> de section index</title>
|
||||
<programlisting>
|
||||
<title>propri<EFBFBD>t<EFBFBD> de {section} index</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* FYI, $custid[customer.index] et $custid[customer] sont identiques *}
|
||||
|
||||
{section name=client loop=$idClient}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -307,47 +473,22 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.index.prev">
|
||||
<title>index_prev</title>
|
||||
<para>
|
||||
index_prev est utilis<69> pour afficher l'index de parcours
|
||||
pr<70>c<EFBFBD>dent de la boucle. Au premier passage, il vaut -1.
|
||||
</para>
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> de section index_prev</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *}
|
||||
{if $idClient[client.index_prev] ne $idClient[client.index]}
|
||||
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
|
||||
{/if}
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'exemple ci-dessus affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
|
||||
1 id: 1001<br />
|
||||
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
|
||||
2 id: 1002<br />
|
||||
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.index.next">
|
||||
<title>index_next</title>
|
||||
<para>
|
||||
@@ -355,17 +496,37 @@ e-mail: jane@myexample.com<p>
|
||||
index. Dans la derni<6E>re boucle, cel<65> reste la valeur incr<63>ment<6E>e,
|
||||
qui respecte l'attribut step si donn<6E>.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> de section index_next</title>
|
||||
<programlisting>
|
||||
<title>propri<EFBFBD>t<EFBFBD> de {section} index_next et index_prev</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *}
|
||||
{if $idClient[client.index_next] ne $idClient[client.index]}
|
||||
L'id du client va changer<br />
|
||||
{/if}
|
||||
{/section}
|
||||
<?php
|
||||
|
||||
$data = array(1001,1002,1003,1004,1005);
|
||||
$smarty->assign('custid',$data);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* FYI, $custid[cus.index] et $custid[cus] sont identiques *}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>index</th><th>id</th>
|
||||
<th>index_prev</th><th>prev_id</th>
|
||||
<th>index_next</th><th>next_id</th>
|
||||
</tr>
|
||||
{section name=cus loop=$custid}
|
||||
<tr>
|
||||
<td>{$smarty.section.cus.index}</td><td>{$custid[cus]}</td>
|
||||
<td>{$smarty.section.cus.index_prev}</td><td>{$custid[cus.index_prev]}</td>
|
||||
<td>{$smarty.section.cus.index_next}</td><td>{$custid[cus.index_next]}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -373,16 +534,17 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
L'id du client va changer<br />
|
||||
1 id: 1001<br />
|
||||
L'id du client va changer<br />
|
||||
2 id: 1002<br />
|
||||
L'id du client va changer<br />
|
||||
index id index_prev prev_id index_next next_id
|
||||
0 1001 -1 1 1002
|
||||
1 1002 0 1001 2 1003
|
||||
2 1003 1 1002 3 1004
|
||||
3 1004 2 1003 4 1005
|
||||
4 1005 3 1004 5
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
@@ -397,17 +559,25 @@ e-mail: jane@myexample.com<p>
|
||||
ils fonctionnent de la m<>me fa<66>on.
|
||||
</para>
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> iteration de section</title>
|
||||
<title>propri<EFBFBD>t<EFBFBD> iteration de {section}</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// Tableau de 3000 <20> 3015
|
||||
$id = range(3000,3015);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient start=5 step=2}
|
||||
Iteration courante: {$smarty.section.client.iteration}<br />
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *}
|
||||
{if $idCLient[client.index_next] ne $idClient[client.index]}
|
||||
L'id du client va changer<br />
|
||||
{/if}
|
||||
{/section}
|
||||
{section name=cu loop=$custid start=5 step=2}
|
||||
iteration={$smarty.section.cu.iteration}
|
||||
index={$smarty.section.cu.index}
|
||||
id={$custid[cu]}<br />
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -415,93 +585,84 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Iteration courante: 1
|
||||
5 id: 1000<br />
|
||||
L'id du client va changer<br />
|
||||
Iteration courante: 2
|
||||
7 id: 1001<br />
|
||||
L'id du client va changer<br />
|
||||
Iteration courante: 3
|
||||
9 id: 1002<br />
|
||||
L'id du client va changer<br />
|
||||
iteration=1 index=5 id=3005<br />
|
||||
iteration=2 index=7 id=3007<br />
|
||||
iteration=3 index=9 id=3009<br />
|
||||
iteration=4 index=11 id=3011<br />
|
||||
iteration=5 index=13 id=3013<br />
|
||||
iteration=6 index=15 id=3015<br />
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Cet exemple utilise la propri<72>t<EFBFBD> iteration pour afficher
|
||||
un block d'en-t<>te de tableau toutes les cinq lignes
|
||||
(utilisez <link linkend="language.function.if">{if}</link>
|
||||
avec l'op<6F>rateur mod).
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<table>
|
||||
{section name=co loop=$contacts}
|
||||
{if $smarty.section.co.iteration % 5 == 1}
|
||||
<tr><th> </th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
|
||||
<td>{$contacts[co].name}</td>
|
||||
<td>{$contacts[co].home}</td>
|
||||
<td>{$contacts[co].cell}</td>
|
||||
<td>{$contacts[co].email}</td>
|
||||
<tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.first">
|
||||
<title>first</title>
|
||||
<para>
|
||||
first est <20> true lorsque la section est parcouru pour la premi<6D>re fois.
|
||||
</para>
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> first de la section</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{if $smarty.section.client.first}
|
||||
<table>
|
||||
{/if}
|
||||
|
||||
<tr><td>{$smarty.section.client.index} id:
|
||||
{$idClient[client]}</td></tr>
|
||||
|
||||
{if $smarty.section.client.last}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'exemple ci-dessus affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.last">
|
||||
<title>last</title>
|
||||
<para>
|
||||
last est <20> true lorsque la section est parcourue pour la derni<6E>re fois.
|
||||
</para>
|
||||
<example>
|
||||
<title>Propri<EFBFBD>t<EFBFBD> last de section</title>
|
||||
<title>Propri<EFBFBD>t<EFBFBD> last et first de {section}</title>
|
||||
<para>
|
||||
Cet exemple boucle le tableau $customers ;
|
||||
affiche un block d'en-t<>te lors de la premi<6D>re it<69>ration et,
|
||||
<20> la derni<6E>re, affiche un block de pied de page
|
||||
(utilisation de la propri<72>t<EFBFBD> <link linkend="section.property.total">total</link>)
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{if $smarty.section.client.first}
|
||||
<table>
|
||||
{/if}
|
||||
{section name=customer loop=$customers}
|
||||
{if $smarty.section.customer.first}
|
||||
<table>
|
||||
<tr><th>id</th><th>customer</th></tr>
|
||||
{/if}
|
||||
|
||||
<tr><td>{$smarty.section.client.index} id:
|
||||
{$idClient[client]}</td></tr>
|
||||
<tr>
|
||||
<td>{$customers[customer].id}}</td>
|
||||
<td>{$customers[customer].name}</td>
|
||||
</tr>
|
||||
|
||||
{if $smarty.section.client.last}
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
{if $smarty.section.customer.last}
|
||||
<tr><td></td><td>{$smarty.section.customer.total} customers</td></tr>
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'exemple ci-dessus affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table>
|
||||
<tr><td>0 id: 1000</td></tr>
|
||||
<tr><td>1 id: 1001</td></tr>
|
||||
<tr><td>2 id: 1002</td></tr>
|
||||
</table>
|
||||
]]>
|
||||
</screen>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.rownum">
|
||||
<title>rownum</title>
|
||||
<para>
|
||||
@@ -510,27 +671,8 @@ e-mail: jane@myexample.com<p>
|
||||
linkend="section.property.iteration">iteration</link>, ils fonctionnent de fa<66>on
|
||||
identique.
|
||||
</para>
|
||||
<example>
|
||||
<title>propri<EFBFBD>t<EFBFBD> rownum de section</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{$smarty.section.client.rownum} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'exemple ci-dessus affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
1 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
3 id: 1002<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.loop">
|
||||
<title>loop</title>
|
||||
<para>
|
||||
@@ -538,14 +680,14 @@ e-mail: jane@myexample.com<p>
|
||||
section a utilis<69>. Peut <20>tre utilis<69> dans ou en dehors de la section.
|
||||
</para>
|
||||
<example>
|
||||
<title>Propri<EFBFBD>t<EFBFBD> de section index</title>
|
||||
<programlisting>
|
||||
<title>Propri<EFBFBD>t<EFBFBD> de {section} index</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient}
|
||||
{section name=client loop=$idClient}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
{/section}
|
||||
|
||||
Il y eu {$smarty.section.client.loop} clients d'affich<63>s.
|
||||
Il y eu {$smarty.section.client.loop} clients d'affich<63>s.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -553,38 +695,41 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
|
||||
il y eu 3 clients d'affich<63>s.
|
||||
Il y eu 3 clients d'affich<63>s.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.show">
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> est utilis<69> comme param<61>tre de section.
|
||||
<emphasis>show</emphasis> est une valeur bool<6F>enne, true ou false.
|
||||
Si show est <20> "false", la section ne sera pas affich<63>e. Si un
|
||||
sectionelse est pr<70>sent, elle sera affich<63>.
|
||||
{sectionelse} est pr<70>sent, elle sera affich<63>e.
|
||||
</para>
|
||||
<example>
|
||||
<title>section, attribut show</title>
|
||||
<title>{section}, attribut show</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* $show_client_info a pu <20>tre pass<73> par le script PHP,
|
||||
pour d<>terminer si oui ou non on souhaite afficher la section *}
|
||||
{section name=client loop=$idClient show=$show_client_info}
|
||||
{*
|
||||
$show_client_info a pu <20>tre pass<73> par le script PHP,
|
||||
pour d<>terminer si oui ou non on souhaite afficher la section
|
||||
*}
|
||||
{section name=client loop=$idClient show=$show_client_info}
|
||||
{$smarty.section.client.rownum} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
{/section}
|
||||
|
||||
{if $smarty.section.client.show}
|
||||
la section <EFBFBD> <20>t<EFBFBD> affich<63>e.
|
||||
{else}
|
||||
la section n'a pas <20>t<EFBFBD> affich<63>e.
|
||||
{/if}
|
||||
{if $smarty.section.client.show}
|
||||
la section a <20>t<EFBFBD> affich<63>e.
|
||||
{else}
|
||||
la section n'a pas <20>t<EFBFBD> affich<63>e.
|
||||
{/if}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -592,30 +737,31 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
1 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
3 id: 1002<br />
|
||||
1 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
3 id: 1002<br />
|
||||
|
||||
la section <EFBFBD> <20>t<EFBFBD> affich<63>e.
|
||||
la section a <20>t<EFBFBD> affich<63>e.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.total">
|
||||
<title>total</title>
|
||||
<para>
|
||||
total est utilis<69> pour afficher le nombre d'it<69>ration que la section
|
||||
<literal>total</literal> est utilis<69> pour afficher le nombre d'it<69>ration que la section
|
||||
va ex<65>cuter. Peut <20>tre utilis<69> dans ou en dehors de la section.
|
||||
</para>
|
||||
<example>
|
||||
<title>section, propri<72>t<EFBFBD> total</title>
|
||||
<title>{section}, propri<72>t<EFBFBD> <literal>total</literal></title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=client loop=$idClient step=2}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
{section name=client loop=$idClient step=2}
|
||||
{$smarty.section.client.index} id: {$idClient[client]}<br />
|
||||
{/section}
|
||||
|
||||
Il y eu {$smarty.section.client.total} clients affich<63>s.
|
||||
Il y eu {$smarty.section.client.total} clients affich<63>s.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -623,21 +769,22 @@ e-mail: jane@myexample.com<p>
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
4 id: 1002<br />
|
||||
0 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
4 id: 1002<br />
|
||||
|
||||
Il y eu 3 clients affich<63>s.
|
||||
Il y eu 3 clients affich<63>s.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
Voir aussi
|
||||
<link linkend="language.function.foreach">{foreach}</link> et
|
||||
<link linkend="language.variables.smarty.loops">$smarty.section</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
@@ -657,4 +804,4 @@ End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
-->
|
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: gerlad Status: ready -->
|
||||
<!-- EN-Revision: 1.8 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.function.strip">
|
||||
<title>strip</title>
|
||||
<title>{strip}</title>
|
||||
<para>
|
||||
Il est fr<66>quent que les designers web rencontrent des probl<62>mes
|
||||
dus aux espaces et retours chariots, qui affectent le rendu HTML
|
||||
@@ -13,7 +14,7 @@
|
||||
<para>
|
||||
Tout contenu situ<74> entre les balises {strip}{/strip} se verra
|
||||
all<6C>g<EFBFBD> des espaces superflus et des retours chariots en d<>but ou en fin
|
||||
de ligne, avant qu'il ne soit affich<63>s. De la sorte, vous pouvez
|
||||
de ligne, avant qu'il ne soit affich<63>. De la sorte, vous pouvez
|
||||
conserver vos templates lisibles, sans vous soucier des effets
|
||||
ind<6E>sirables que peuvent apporter les espaces superflus.
|
||||
</para>
|
||||
@@ -21,8 +22,8 @@
|
||||
<title>Note technique</title>
|
||||
<para>
|
||||
{strip}{/strip} n'affecte en aucun cas le contenu des variables de
|
||||
template. Voir le <link linkend="language.modifier.strip">modificateur
|
||||
strip</link> pour un rendu identique pour les variables.
|
||||
template. Voir aussi le <link linkend="language.modifier.strip">modificateur
|
||||
strip</link> pour un rendu identique pour les variables.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
@@ -31,12 +32,12 @@
|
||||
<![CDATA[
|
||||
{* la suite sera affich<63>e sur une seule ligne *}
|
||||
{strip}
|
||||
<table border=0>
|
||||
<table border='0'>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$url}">
|
||||
<a href="{$url}">
|
||||
<font color="red">Un test</font>
|
||||
</A>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -48,7 +49,7 @@
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table border=0><tr><td><A HREF="http://mon.example.com"><font color="red">Un test</font></A></td></tr></table>
|
||||
<table border='0'><tr><td><a href="http://mon.example.com"><font color="red">Un test</font></a></td></tr></table>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
@@ -59,7 +60,12 @@
|
||||
au suivant/pr<70>c<EFBFBD>dent et risque de ne pas <20>tre affich<63> selon
|
||||
l'effet d<>sir<69>.
|
||||
</para>
|
||||
<para>
|
||||
Voir aussi
|
||||
le <link linkend="language.modifier.strip">modificateur strip</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
@@ -79,4 +85,4 @@ End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
-->
|
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.7 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.assigned.variables">
|
||||
<title>Variables assign<67>es depuis PHP</title>
|
||||
<para>
|
||||
Pour utiliser une variables assign<EFBFBD>es depuis PHP, il
|
||||
Pour utiliser une variables <link linkend="api.assign">assign<EFBFBD>es</link> depuis PHP, il
|
||||
faut la pr<70>fixer par le symbole dollar <literal>$</literal>.
|
||||
Les variables asign<67>es depuis un template gr<67>ce <20> la fonction
|
||||
<link linkend="language.function.assign">{assign}</link> sont
|
||||
@@ -12,21 +13,44 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>Variables assign<67>es</title>
|
||||
<programlisting>
|
||||
<para>Script PHP</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
Bienvenue {$prenom}, heureux de voir que tu es arriv<69> ici.
|
||||
<p>
|
||||
La derni<6E>re connexion remonte au {$dateConnexionPrecedente}.
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->assign('firstname', 'Doug');
|
||||
$smarty->assign('lastname', 'Evans');
|
||||
$smarty->assign('meetingPlace', 'New York');
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Cel<EFBFBD> va afficher:
|
||||
</para>
|
||||
</programlisting>
|
||||
<para>
|
||||
o<> index.tpl est :
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Bonjour {$firstname} {$lastname}, heureux de voir que tu es arriv<69> ici.
|
||||
<br />
|
||||
{* ceci ne fonctionnera pas car $vars est sensible <20> la casse *}
|
||||
Cette semaine, le meeting est <20> {$meetingplace}.
|
||||
{* ceci fonctionnera *}
|
||||
Cette semaine, le meeting est <20> {$meetingPlace}.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Cel<65> va afficher:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Bienvenue Doug, heureux de voir que tu es arriv<69> ici.
|
||||
<p>
|
||||
La derni<6E>re connexion remonte au 11 janvier 2001.
|
||||
<br />
|
||||
Cette semaine, le meeting est <20> .
|
||||
Cette semaine, le meeting est <20> New York.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
@@ -44,12 +68,13 @@ La derni
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('fax' => '555-222-9876',
|
||||
'email' => 'zaphod@slartibartfast.com',
|
||||
'email' => 'zaphod@slartibartfast.example.com',
|
||||
'phone' => array('home' => '555-444-3333',
|
||||
'cell' => '555-111-1234')));
|
||||
'cell' => '555-111-1234')
|
||||
)
|
||||
);
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
@@ -72,7 +97,7 @@ $smarty->display('index.tpl');
|
||||
<screen>
|
||||
<![CDATA[
|
||||
555-222-9876<br />
|
||||
zaphod@slartibartfast.com<br />
|
||||
zaphod@slartibartfast.example.com<br />
|
||||
555-444-3333<br />
|
||||
555-111-1234<br />
|
||||
]]>
|
||||
@@ -91,12 +116,12 @@ zaphod@slartibartfast.com<br />
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('555-222-9876',
|
||||
'zaphod@slartibartfast.com',
|
||||
array('555-444-3333',
|
||||
'555-111-1234')));
|
||||
$smarty->assign('Contacts', array(
|
||||
'555-222-9876',
|
||||
'zaphod@slartibartfast.example.com',
|
||||
array('555-444-3333',
|
||||
'555-111-1234')
|
||||
));
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
@@ -119,7 +144,7 @@ $smarty->display('index.tpl');
|
||||
<screen>
|
||||
<![CDATA[
|
||||
555-222-9876<br />
|
||||
zaphod@slartibartfast.com<br />
|
||||
zaphod@slartibartfast.example.com<br />
|
||||
555-444-3333<br />
|
||||
555-111-1234<br />
|
||||
]]>
|
||||
@@ -142,12 +167,12 @@ email: {$person->email}<br />
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Ce qui donne en sortie :
|
||||
Ce qui donne en sortie :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
nom: Zaphod Beeblebrox<br />
|
||||
email: zaphod@slartibartfast.com<br />
|
||||
email: zaphod@slartibartfast.example.com<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.config.variables">
|
||||
<title>Variables charg<72>es depuis des fichiers de configuration</title>
|
||||
<para>
|
||||
@@ -93,6 +94,17 @@ rowBgColor = "#cccccc"
|
||||
<link linkend="language.syntax.variables">variables</link> et les
|
||||
<link linkend="language.variables.smarty">variables r<>serv<72>es $smarty</link>.
|
||||
</para>
|
||||
<para>
|
||||
Les variables des fichiers de configuration ne peuvent pas <20>tre utilis<69>es
|
||||
tant qu'elles n'ont pas <20>t<EFBFBD> charg<72>es depuis un fichier de configuration. Cette proc<6F>dure
|
||||
est expliqu<71> plus loin dans cette documentation sous la section
|
||||
<link linkend="language.function.config.load"><command>{config_load}</command></link>.
|
||||
</para>
|
||||
<para>
|
||||
Voir aussi
|
||||
les <link linkend="language.syntax.variables">variables</link> et
|
||||
les <link linkend="language.variables.smarty">variables r<>serv<72>es $smarty</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,39 +1,43 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.8 Maintainer: gerald Status: ready -->
|
||||
<!-- EN-Revision: 1.12 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.variables.smarty">
|
||||
<title>Variable r<>serv<72>e {$smarty}</title>
|
||||
<para>
|
||||
La variable r<>serv<72>e {$smarty} peut <20>tre utilis<69>e pour acc<63>der <20> plusieurs
|
||||
La variable PHP r<EFBFBD>serv<EFBFBD>e {$smarty} peut <20>tre utilis<69>e pour acc<63>der <20> plusieurs
|
||||
variables sp<73>ciales du template. En voici la liste compl<70>te.
|
||||
</para>
|
||||
|
||||
<sect2 id="language.variables.smarty.request">
|
||||
<title>Variables de requ<71>te</title>
|
||||
<para>
|
||||
Les variables de requ<71>te comme GET, POST, COOKIES, SERVER, ENVIRONNEMENT
|
||||
et SESSION peuvent <20>tre utilis<69>es comme dans l'exemple suivant:
|
||||
Les <ulink url="&url.php-manual;reserved.variables">variables de requ<71>te</ulink>
|
||||
comme $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
|
||||
(voir <link linkend="variable.request.vars.order">$request_vars_order</link>
|
||||
et <link linkend="variable.request.use.auto.globals">$request_use_auto_globals</link>)
|
||||
peuvent <20>tre utilis<69>es comme dans l'exemple suivant:
|
||||
</para>
|
||||
<example>
|
||||
<title>Afficher des variables de requ<71>te</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Affiche la valeur de page dans l'url (GET) http://www.example.com/index.php?page=foo *}
|
||||
{* Affiche la valeur de page dans l'url ($_GET) http://www.example.com/index.php?page=foo *}
|
||||
{$smarty.get.page}
|
||||
|
||||
{* affiche la variable "page" r<>cup<75>r<EFBFBD>e depuis un formulaire (POST) *}
|
||||
{* affiche la variable "page" r<>cup<75>r<EFBFBD>e depuis un formulaire ($_POST['page']) *}
|
||||
{$smarty.post.page}
|
||||
|
||||
{* affiche la valeur du cookie "utilisateur" *}
|
||||
{* affiche la valeur du cookie "utilisateur" ($_COOKIE['username']) *}
|
||||
{$smarty.cookies.utilisateur}
|
||||
|
||||
{* affiche la variable serveur "SERVER_NAME" *}
|
||||
{* affiche la variable serveur "SERVER_NAME" ($_SERVER['SERVER_NAME']) *}
|
||||
{$smarty.server.SERVER_NAME}
|
||||
|
||||
{* affiche la variable d'environnement "PATH" *}
|
||||
{$smarty.env.PATH}
|
||||
|
||||
{* affiche la variable de session PHP "id" *}
|
||||
{* affiche la variable de session PHP "id" ($_SESSION['id']) *}
|
||||
{$smarty.session.id}
|
||||
|
||||
{* affiche la variable "utilisateur" du regroupement de get/post/cookies/server/env *}
|
||||
@@ -41,19 +45,27 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
<para>
|
||||
Pour des raisons historiques, {$SCRIPT_NAME} peut <20>tre acc<63>d<EFBFBD>
|
||||
directement, cependant, {$smarty.server.SCRIPT_NAME} est
|
||||
la solution propos<6F>e pour acc<63>der <20> cette valeur.
|
||||
</para>
|
||||
</note>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.now">
|
||||
<title>{$smarty.now}</title>
|
||||
<para>
|
||||
Le timestamp courant peut <20>tre r<>cup<75>r<EFBFBD> gr<67>ce <20> {$smarty.now}.
|
||||
Le <ulink url="&url.php-manual;function.time">timestamp</ulink>
|
||||
courant peut <20>tre r<>cup<75>r<EFBFBD> gr<67>ce <20> {$smarty.now}.
|
||||
Le nombre obtenu correspond au nombre de secondes <20>coul<75>es depuis
|
||||
Epoch (1 Janvier 1970) et peut <20>tre pass<73> directement au modificateur
|
||||
de variable date <link linkend="language.modifier.date.format">date_format</link>
|
||||
<20> des fins d'affichage.
|
||||
</para>
|
||||
<example>
|
||||
<title>utilisation de {$smarty.now}</title>
|
||||
<title>Utilisation de {$smarty.now}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* utilise le modificateur de variable date_format pour afficher la date et heure *}
|
||||
@@ -62,12 +74,12 @@
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.const">
|
||||
<title>{$smarty.const}</title>
|
||||
<para>
|
||||
Vous pouvez directement acc<63>der aux constantes PHP.
|
||||
Voir aussi les <link
|
||||
linkend="smarty.constants">constantes smarty</link>.
|
||||
Voir aussi les <link linkend="smarty.constants">constantes smarty</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Utiliser {$smarty.const}</title>
|
||||
@@ -82,7 +94,7 @@
|
||||
<sect2 id="language.variables.smarty.capture">
|
||||
<title>{$smarty.capture}</title>
|
||||
<para>
|
||||
La capture r<>alis<69>e via
|
||||
La capture r<>alis<69>e via
|
||||
<link linkend="language.function.capture">{capture}..{/capture}</link>
|
||||
peut <20>tre r<>cup<75>r<EFBFBD>e par l'interm<72>diaire de la variable {$smarty}. Voir la section
|
||||
sur <link linkend="language.function.capture">{capture}</link> pour un
|
||||
@@ -93,11 +105,10 @@
|
||||
<sect2 id="language.variables.smarty.config">
|
||||
<title>{$smarty.config}</title>
|
||||
<para>
|
||||
La variable {$smarty} peut <20>tre utilis<69>e pour d<>signer une <link
|
||||
linkend="language.config.variables">variable
|
||||
d'un fichier de configuration</link>. {$smarty.config.foo} est un synonyme de
|
||||
{#foo#}. Voir la section <link
|
||||
linkend="language.function.config.load">{config_load}</link>
|
||||
La variable {$smarty} peut <20>tre utilis<69>e pour d<>signer une
|
||||
<link linkend="language.config.variables">variable d'un fichier de configuration</link>.
|
||||
{$smarty.config.foo} est un synonyme de {#foo#}. Voir la section
|
||||
<link linkend="language.function.config.load">{config_load}</link>
|
||||
pour un exemple <20> ce sujet.
|
||||
</para>
|
||||
</sect2>
|
||||
@@ -118,17 +129,24 @@
|
||||
Cette variable contient le nom du template en cours de traitement.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.version">
|
||||
<title>{$smarty.version}</title>
|
||||
<para>
|
||||
Cette variable contient la version de Smarty utilis<69>e pour compiler un template.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.ldelim">
|
||||
<title>{$smarty.ldelim}, {$smarty.rdelim}</title>
|
||||
<para>
|
||||
Cette variable est utilis<69>e pour afficher le d<>l<EFBFBD>miteur gauche et le d<>limiteur droit. Lisez aussi
|
||||
la partie <link
|
||||
linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
|
||||
la partie <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
|
||||
</para>
|
||||
<para>
|
||||
Voir aussi les
|
||||
<link linkend="language.syntax.variables">variables</link> et les
|
||||
<link linkend="language.config.variables">variables de configuration</link>.
|
||||
Voir aussi
|
||||
les <link linkend="language.syntax.variables">variables</link> et
|
||||
les <link linkend="language.config.variables">variables de configuration</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.10 Maintainer: didou Status: ready -->
|
||||
<!-- EN-Revision: 1.13 Maintainer: yannick Status: ready -->
|
||||
|
||||
<part id="getting.started">
|
||||
<title>Pour commencer</title>
|
||||
|
||||
@@ -155,7 +156,7 @@
|
||||
<sect1 id="installing.smarty.basic">
|
||||
<title>Installation de base</title>
|
||||
<para>
|
||||
Copiez les fichiers biblioth<74>ques de Smarty du r<EFBFBD>pertoire
|
||||
Copiez les fichiers biblioth<74>ques de Smarty du sous-dossier
|
||||
/libs/ de la distribution <20> un emplacement accessible <20> PHP.
|
||||
Ce sont des fichiers PHP que vous NE DEVEZ PAS
|
||||
modifier. Ils sont partag<61>s par toutes les applications et ne seront
|
||||
@@ -177,18 +178,18 @@ debug.tpl
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Smarty utilise une constante PHP appel<65>e <link
|
||||
Smarty utilise une <ulink url="&url.php-manual;define">constante</ulink> PHP appel<65>e <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> qui
|
||||
repr<70>sente le chemin complet de la biblioth<74>que Smarty. En fait,
|
||||
repr<70>sente le <emphasis role="bold">chemin complet</emphasis> de la biblioth<74>que Smarty. En fait,
|
||||
si votre application trouve le fichier
|
||||
<filename>Smarty.class.php</filename>, vous n'aurez pas
|
||||
besoin de d<>finir la variable <link linkend="constant.smarty.dir">SMARTY_DIR</link>,
|
||||
besoin de d<>finir la variable <link linkend="constant.smarty.dir">SMARTY_DIR</link>,
|
||||
Smarty s'en chargera pour vous.
|
||||
En revanche, si <filename>Smarty.class.php</filename>
|
||||
n'est pas dans votre r<>pertoire d'inclusion ou que vous ne
|
||||
donnez pas un chemin absolu <20> votre application, vous
|
||||
devez d<>finir SMARTY_DIR explicitement. SMARTY_DIR
|
||||
<emphasis>doit</emphasis> avoir <20>tre termin<69> par un slash.
|
||||
<emphasis role="bold">doit</emphasis> avoir <20>tre termin<69> par un slash.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -200,8 +201,9 @@ debug.tpl
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
// Note : Smarty a un 'S' majuscule
|
||||
require_once('Smarty.class.php');
|
||||
$smarty = new Smarty();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -214,40 +216,50 @@ $smarty = new Smarty;
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>fournir un chemin absolu vers la biblioth<74>que Smarty</title>
|
||||
<title>D<EFBFBD>finition manuelle de la constante SMARTY_DIR</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require('/usr/local/lib/php/Smarty/Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
// Style *nix (notez le 'S' majuscule)
|
||||
define('SMARTY_DIR', '/usr/local/lib/php/Smarty-v.e.r/libs/');
|
||||
|
||||
// Style Windows
|
||||
define('SMARTY_DIR', 'c:/webroot/libs/Smarty-v.e.r/libs/');
|
||||
|
||||
require_once(SMARTY_DIR . 'Smarty.class.php');
|
||||
$smarty = new Smarty();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Ajouter le r<>pertoire de la biblioth<74>que dans l'include_path de PHP</title>
|
||||
<title>D<EFBFBD>finir le chemin absolu au fichier de la biblioth<74>que</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Editez votre fichier php.ini file, ajoutez le chemin de la
|
||||
// biblioth<74>que Smarty et red<65>marrez les serveur web.
|
||||
// la ligne suivante doit alors fonctionner :
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
// Style *nix (notez le 'S' majuscule)
|
||||
require_once('/usr/local/lib/php/Smarty-v.e.r/libs/Smarty.class.php');
|
||||
|
||||
// Style Windows
|
||||
require_once('c:/webroot/libs/Smarty-v.e.r/libs/Smarty.class.php');
|
||||
|
||||
$smarty = new Smarty();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>D<EFBFBD>finir explicitement la constante SMARTY_DIR</title>
|
||||
<title>Ajout du dossier contenant la biblioth<74>que <20> l'include_path de PHP</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
define('SMARTY_DIR', '/usr/local/lib/php/Smarty/');
|
||||
require(SMARTY_DIR . 'Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
// Editez votre fichier php.ini, ajoutez le dossier contenant la
|
||||
// biblioth<74>que Smarty <20> l'include_path et red<65>marrez le serveur web.
|
||||
// Puis, ce qui suit devrait fonctionner :
|
||||
require_once('Smarty.class.php');
|
||||
$smarty = new Smarty();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -258,7 +270,7 @@ $smarty = new Smarty;
|
||||
il est temps de d<>finir les r<>pertoires de Smarty, pour votre application.
|
||||
</para>
|
||||
<para>
|
||||
Smarty a besoin de quatre r<>pertoires qui sont (par d<>faut)
|
||||
Smarty a besoin de quatre r<>pertoires qui sont, par d<>faut,
|
||||
<filename class="directory">'templates/'</filename>,
|
||||
<filename class="directory">'templates_c/'</filename>,
|
||||
<filename class="directory">'configs/'</filename> et
|
||||
@@ -332,19 +344,19 @@ $smarty = new Smarty;
|
||||
<title>Exemple de structure de fichiers</title>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
/usr/local/lib/php/Smarty/Smarty.class.php
|
||||
/usr/local/lib/php/Smarty/Smarty_Compiler.class.php
|
||||
/usr/local/lib/php/Smarty/Config_File.class.php
|
||||
/usr/local/lib/php/Smarty/debug.tpl
|
||||
/usr/local/lib/php/Smarty/internals/*.php
|
||||
/usr/local/lib/php/Smarty/plugins/*.php
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/Smarty.class.php
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/Smarty_Compiler.class.php
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/Config_File.class.php
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/debug.tpl
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/internals/*.php
|
||||
/usr/local/lib/php/Smarty-v.e.r/libs/plugins/*.php
|
||||
|
||||
/web/www.example.com/smarty/livredor/templates/
|
||||
/web/www.example.com/smarty/livredor/templates_c/
|
||||
/web/www.example.com/smarty/livredor/configs/
|
||||
/web/www.example.com/smarty/livredor/cache/
|
||||
/web/www.example.com/smarty/guestbook/templates/
|
||||
/web/www.example.com/smarty/guestbook/templates_c/
|
||||
/web/www.example.com/smarty/guestbook/configs/
|
||||
/web/www.example.com/smarty/guestbook/cache/
|
||||
|
||||
/web/www.example.com/docs/livredor/index.php
|
||||
/web/www.example.com/docs/guestbook/index.php
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
@@ -389,7 +401,7 @@ chmod 770 /web/www.example.com/smarty/livredor/cache/
|
||||
|
||||
<para>
|
||||
Nous devons cr<63>er le fichier 'index.tpl' que Smarty va charger.
|
||||
Il va se trouver dans <link linkend="variable.template.dir">$template_dir</link>.
|
||||
Il va se trouver dans le dossier <link linkend="variable.template.dir">$template_dir</link>.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
@@ -399,7 +411,7 @@ chmod 770 /web/www.example.com/smarty/livredor/cache/
|
||||
|
||||
{* Smarty *}
|
||||
|
||||
Hello, {$name}!
|
||||
Bonjour, {$name}, Bienvenue dans Smarty !
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
@@ -419,34 +431,32 @@ Hello, {$name}!
|
||||
|
||||
<para>
|
||||
Maintenant passons <20> l'<27>dition du fichier 'index.php'. Nous allons
|
||||
cr<63>er une instance de Smarty, assigner une valeur <20> une variable
|
||||
de template et afficher le r<>sultat avec 'index.tpl'. Dans notre
|
||||
exemple d'environnement, "/usr/local/lib/php/Smarty" est dans notre
|
||||
include_path. Assurez-vous de faire la m<>me chose ou d'utiliser
|
||||
des chemins absolus.
|
||||
cr<63>er une instance de Smarty, <link linkend="api.assign">assigner</link>
|
||||
une valeur <20> une variable de template et
|
||||
<link linkend="api.display">afficher</link> le r<>sultat avec 'index.tpl'.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title><EFBFBD>dition de /web/www.example.com/docs/livredor/index.php</title>
|
||||
<screen>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// charge la biblioth<74>que Smarty
|
||||
require('Smarty.class.php');
|
||||
// charge la biblioth<74>que Smarty
|
||||
require_once(SMARTY_DIR . 'Smarty.class.php');
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty = new Smarty();
|
||||
|
||||
$smarty->template_dir = '/web/www.example.com/smarty/livredor/templates/';
|
||||
$smarty->compile_dir = '/web/www.example.com/smarty/livredor/templates_c/';
|
||||
$smarty->config_dir = '/web/www.example.com/smarty/livredor/configs/';
|
||||
$smarty->cache_dir = '/web/www.example.com/smarty/livredor/cache/';
|
||||
$smarty->template_dir = '/web/www.example.com/smarty/livredor/templates/';
|
||||
$smarty->compile_dir = '/web/www.example.com/smarty/livredor/templates_c/';
|
||||
$smarty->config_dir = '/web/www.example.com/smarty/livredor/configs/';
|
||||
$smarty->cache_dir = '/web/www.example.com/smarty/livredor/cache/';
|
||||
|
||||
$smarty->assign('name','Ned');
|
||||
$smarty->assign('name','Ned');
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
</screen>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<note>
|
||||
@@ -465,7 +475,7 @@ Hello, {$name}!
|
||||
|
||||
<para>
|
||||
Et maintenant appelez le fichier <filename>index.php</filename> avec navigateur
|
||||
Web. Vous devriez voir "Hello, Ned!".
|
||||
Web. Vous devriez voir "Bonjour, Ned, Bienvenue dans Smarty !".
|
||||
</para>
|
||||
<para>
|
||||
Vous venez de terminer l'installation de base de Smarty !
|
||||
|
Reference in New Issue
Block a user