mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-11 17:43:50 +01:00
sync with EN
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.14 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.17 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="language.function.html.options">
|
||||
<title>{html_options}</title>
|
||||
<para>
|
||||
{html_options} est une
|
||||
<varname>{html_options}</varname> est une
|
||||
<link linkend="language.custom.functions">fonction personnalis<69>e</link>
|
||||
qui cr<63>e un groupe d'options avec les donn<6E>es fournies. Elle prend en charge
|
||||
les <20>l<EFBFBD>ments s<>lectionn<6E>s par d<>faut. Les attributs requis sont values et output,
|
||||
<20> moins que vous n'utilisiez options <20> la place.
|
||||
les <20>l<EFBFBD>ments s<>lectionn<6E>s par d<>faut.
|
||||
</para>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
@@ -32,19 +31,19 @@
|
||||
<entry>values</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Oui, <20> moins que vous n'utilisiez
|
||||
l'attribut options</entry>
|
||||
l'attribut options</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>un tableau de valeurs pour les listes
|
||||
d<>roulantes</entry>
|
||||
<entry>Un tableau de valeurs pour les listes
|
||||
d<EFBFBD>roulantes</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>output</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Oui, <20> moins que vous n'utilisiez
|
||||
l'attribut options</entry>
|
||||
l'attribut options</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>Un tableau de libell<6C>s pour la liste
|
||||
d<>roulante</entry>
|
||||
d<EFBFBD>roulante</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>selected</entry>
|
||||
@@ -57,7 +56,7 @@
|
||||
<entry>options</entry>
|
||||
<entry>Tableau associatif</entry>
|
||||
<entry>Oui, <20> moins que vous n'utilisiez option
|
||||
et values</entry>
|
||||
et values</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>Un tableau associatif valeur / libell<6C></entry>
|
||||
</row>
|
||||
@@ -71,94 +70,120 @@
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Si la valeur donn<6E>e est un tableau, elle sera trait<69>e comme un
|
||||
<optgroup> html, et affich<63>e. La r<>cursivit<69> est support<72>e avec
|
||||
<optgroup>. La sortie est compatible XHTML.
|
||||
</para>
|
||||
<para>
|
||||
Si l'attribut optionnel <emphasis>name</emphasis> est donn<6E>, les
|
||||
balises <select name="groupname"></select> entoureront la
|
||||
liste d'options. Sinon, seule la liste <option> sera g<>n<EFBFBD>r<EFBFBD>e.
|
||||
</para>
|
||||
<para>
|
||||
Tous les param<61>tres qui ne sont pas dans la liste ci-dessus sont
|
||||
affich<EFBFBD>s en tant que paires nom / valeur dans la balise <select>. Ils
|
||||
sont ignor<6F>s si le param<61>tre optionnel <emphasis>name</emphasis>
|
||||
n'est pas donn<6E>.
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
Les attributs requis sont
|
||||
<parameter>values</parameter> et <parameter>output</parameter>,
|
||||
<20> moins que vous n'utilisiez <parameter>options</parameter> <20> la place.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Si l'attribut optionnel <parameter>name</parameter> est fourni, les balises
|
||||
<literal><select></select></literal> seront cr<63><72>es,
|
||||
sinon, UNIQUEMENT la liste <literal><option></literal> sera g<>n<EFBFBD>r<EFBFBD>e.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Si la valeur fournie est un tableau, il sera trait<69> comme un
|
||||
<literal><optgroup></literal> HTML, et affichera les groupes.
|
||||
La r<>cursivit<69> est support<72>e avec <literal><optgroup></literal>.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Tous les param<61>tres qui ne sont pas dans la liste ci-dessus sont affich<63>s
|
||||
sous la forme de paire nom/valeur dans la balise
|
||||
<literal><select></literal>. Ils seront ignor<6F>s si le param<61>tre optionnel
|
||||
<parameter>name</parameter> n'est pas fourni.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Tous les affichages sont conformes XHTML.
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<example>
|
||||
<title>{html_options}</title>
|
||||
<para>
|
||||
<emphasis role="bold">Exemple 1 :</emphasis>
|
||||
</para>
|
||||
<title>Un tableau associatif avec l'attribut <varname>options</varname></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array(
|
||||
'Joe Schmoe',
|
||||
'Jack Smith',
|
||||
'Jane Johnson',
|
||||
'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
$smarty->assign('myOptions', array(
|
||||
1800 => 'Joe Schmoe',
|
||||
9904 => 'Jack Smith',
|
||||
2003 => 'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('mySelect', 9904);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
O<EFBFBD> le template est :
|
||||
Le template suivant g<>n<EFBFBD>rera une liste. Notez la pr<70>sence
|
||||
de l'attribut <parameter>name</parameter> qui cr<63>e les
|
||||
balises <literal><select></literal>.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name="customer_id">
|
||||
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
||||
{html_options name=foo options=$myOptions selected=$mySelect}
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
L'affichage de l'exemple ci-dessus sera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name="foo">
|
||||
<option label="Joe Schmoe" value="1800">Joe Schmoe</option>
|
||||
<option label="Jack Smith" value="9904" selected="selected">Jack Smith</option>
|
||||
<option label="Charlie Brown" value="2003">Charlie Brown</option>
|
||||
</select>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Tableaux s<>par<61>s pour <varname>values</varname> et
|
||||
<varname>ouptut</varname></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty->assign('cust_ids', array(56,92,13));
|
||||
$smarty->assign('cust_names', array(
|
||||
'Joe Schmoe',
|
||||
'Jane Johnson',
|
||||
'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 92);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Les tableaux ci-dessus seront affich<63>s avec le template suivant
|
||||
(notez l'utilisation de la fonction PHP <ulink url="&url.php-manual;function.count">
|
||||
<varname>count()</varname></ulink> en tant que modificateur pour
|
||||
d<>finir la taille du select).
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name="customer_id" size="{$cust_names|@count}">
|
||||
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<emphasis role="bold">Exemple 2 :</emphasis>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('cust_options', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
O<> le template est :
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_options name=customer_id options=$cust_options selected=$customer_id}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Les deux exemples afficheront :
|
||||
L'exemple ci-dessous affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name="customer_id">
|
||||
<option label="Joe Schmoe" value="1000">Joe Schmoe</option>
|
||||
<option label="Jack Smith" value="1001" selected="selected">Jack Smith</option>
|
||||
<option label="Jane Johnson" value="1002">Jane Johnson</option>
|
||||
<option label="Charlie Brown" value="1003">Charlie Brown</option>
|
||||
<option label="Joe Schmoe" value="56">Joe Schmoe</option>
|
||||
<option label="Jack Smith" value="92" selected="selected">Jane Johnson</option>
|
||||
<option label="Charlie Brown" value="13">Charlie Brown</option>
|
||||
</select>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>{html_options} - Exemple avec une base de donn<6E>es (eg PEAR ou ADODB):</title>
|
||||
<title>Exemple avec une base de donn<6E>es (e.g. ADODB ou PEAR)</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -167,30 +192,72 @@ $sql = 'select type_id, types from contact_types order by type';
|
||||
$smarty->assign('contact_types',$db->getAssoc($sql));
|
||||
|
||||
$sql = 'select contact_id, name, email, contact_type_id
|
||||
from contacts where contact_id='.$contact_id;
|
||||
from contacts where contact_id='.$contact_id;
|
||||
$smarty->assign('contact',$db->getRow($sql));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
o<EFBFBD> le template est :
|
||||
O<EFBFBD> le template pourrait <20>tre celui-ci. Notez l'utilisation du modificateur
|
||||
<link linkend="language.modifier.truncate"><varname>truncate</varname></link>.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name="type_id">
|
||||
<option value='null'>-- none --</option>
|
||||
{html_options options=$contact_types selected=$contact.type_id}
|
||||
{html_options options=$contact_types|truncate:20 selected=$contact.type_id}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="language.function.html.checkboxes">{html_checkboxes}</link> et
|
||||
<link linkend="language.function.html.radios">{html_radios}</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<example>
|
||||
<title>Exemple avec <optgroup> </title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$arr['Sport'] = array(6 => 'Golf', 9 => 'Cricket',7 => 'Swim');
|
||||
$arr['Rest'] = array(3 => 'Sauna',1 => 'Massage');
|
||||
$smarty->assign('lookups', $arr);
|
||||
$smarty->assign('fav', 7);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>Le script ci-dessus et le template suivant
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_options name=foo options=$myOptions selected=$mySelect}
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
affichera :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name="breakTime">
|
||||
<optgroup label="Sport">
|
||||
<option label="Golf" value="6">Golf</option>
|
||||
<option label="Cricket" value="9">Cricket</option>
|
||||
<option label="Swim" value="7" selected="selected">Swim</option>
|
||||
</optgroup>
|
||||
<optgroup label="Rest">
|
||||
<option label="Sauna" value="3">Sauna</option>
|
||||
<option label="Massage" value="1">Massage</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="language.function.html.checkboxes"><varname>{html_checkboxes}</varname></link>
|
||||
et
|
||||
<link linkend="language.function.html.radios"><varname>{html_radios}</varname></link>
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
||||
Reference in New Issue
Block a user