2004-04-13 15:43:47 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<!-- EN-Revision: 1.17 Maintainer: yannick Status: ready -->
|
2005-12-04 17:56:06 +00:00
|
|
|
|
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<sect1 id="language.function.html.options">
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<title>{html_options}</title>
|
|
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<varname>{html_options}</varname> est une
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<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
|
2006-10-01 20:03:00 +00:00
|
|
|
|
les <20>l<EFBFBD>ments s<>lectionn<6E>s par d<>faut.
|
2005-12-04 17:56:06 +00:00
|
|
|
|
</para>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<informaltable frame="all">
|
|
|
|
|
|
<tgroup cols="5">
|
|
|
|
|
|
<colspec colname="param" align="center" />
|
|
|
|
|
|
<colspec colname="type" align="center" />
|
|
|
|
|
|
<colspec colname="required" align="center" />
|
|
|
|
|
|
<colspec colname="default" align="center" />
|
|
|
|
|
|
<colspec colname="desc" />
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>Nom attribut</entry>
|
|
|
|
|
|
<entry>Type</entry>
|
|
|
|
|
|
<entry>Requis</entry>
|
|
|
|
|
|
<entry>Defaut</entry>
|
|
|
|
|
|
<entry>Description</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>values</entry>
|
|
|
|
|
|
<entry>array</entry>
|
|
|
|
|
|
<entry>Oui, <20> moins que vous n'utilisiez
|
2006-10-01 20:03:00 +00:00
|
|
|
|
l'attribut options</entry>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<entry>Un tableau de valeurs pour les listes
|
|
|
|
|
|
d<>roulantes</entry>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>output</entry>
|
|
|
|
|
|
<entry>array</entry>
|
|
|
|
|
|
<entry>Oui, <20> moins que vous n'utilisiez
|
2006-10-01 20:03:00 +00:00
|
|
|
|
l'attribut options</entry>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Un tableau de libell<6C>s pour la liste
|
2006-10-01 20:03:00 +00:00
|
|
|
|
d<>roulante</entry>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>selected</entry>
|
|
|
|
|
|
<entry>cha<EFBFBD>ne de caract<63>res/tableau</entry>
|
|
|
|
|
|
<entry>Non</entry>
|
|
|
|
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
|
|
|
|
<entry>Les <20>l<EFBFBD>ments s<>lectionn<6E>s</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>options</entry>
|
|
|
|
|
|
<entry>Tableau associatif</entry>
|
|
|
|
|
|
<entry>Oui, <20> moins que vous n'utilisiez option
|
2006-10-01 20:03:00 +00:00
|
|
|
|
et values</entry>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Un tableau associatif valeur / libell<6C></entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>name</entry>
|
|
|
|
|
|
<entry>cha<EFBFBD>ne de caract<63>res</entry>
|
|
|
|
|
|
<entry>Non</entry>
|
|
|
|
|
|
<entry><emphasis>empty</emphasis></entry>
|
|
|
|
|
|
<entry>Nom du goupe d'options</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</tgroup>
|
|
|
|
|
|
</informaltable>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<example>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<title>Un tableau associatif avec l'attribut <varname>options</varname></title>
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<programlisting role="php">
|
2004-12-22 19:59:35 +00:00
|
|
|
|
<![CDATA[
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<?php
|
2006-10-01 20:03:00 +00:00
|
|
|
|
$smarty->assign('myOptions', array(
|
|
|
|
|
|
1800 => 'Joe Schmoe',
|
|
|
|
|
|
9904 => 'Jack Smith',
|
|
|
|
|
|
2003 => 'Charlie Brown')
|
|
|
|
|
|
);
|
|
|
|
|
|
$smarty->assign('mySelect', 9904);
|
2005-12-04 17:56:06 +00:00
|
|
|
|
?>
|
2005-05-11 09:47:36 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
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>.
|
2005-05-11 09:47:36 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2006-10-01 20:03:00 +00:00
|
|
|
|
{html_options name=foo options=$myOptions selected=$mySelect}
|
2005-05-11 09:47:36 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
|
2005-05-11 09:47:36 +00:00
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
L'affichage de l'exemple ci-dessus sera :
|
2005-05-11 09:47:36 +00:00
|
|
|
|
</para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<screen>
|
2005-05-11 09:47:36 +00:00
|
|
|
|
<![CDATA[
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<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>
|
2004-04-13 15:43:47 +00:00
|
|
|
|
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<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);
|
2005-12-04 17:56:06 +00:00
|
|
|
|
?>
|
2005-05-11 09:47:36 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
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).
|
2005-05-11 09:47:36 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<select name="customer_id" size="{$cust_names|@count}">
|
|
|
|
|
|
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
|
|
|
|
|
</select>
|
2005-05-11 09:47:36 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
L'exemple ci-dessous affichera :
|
2005-05-11 09:47:36 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<select name="customer_id">
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<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>
|
2004-12-22 19:59:35 +00:00
|
|
|
|
</select>
|
|
|
|
|
|
]]>
|
2005-05-11 09:47:36 +00:00
|
|
|
|
</screen>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</example>
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<example>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
<title>Exemple avec une base de donn<6E>es (e.g. ADODB ou PEAR)</title>
|
2005-12-04 17:56:06 +00:00
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
2006-03-22 17:30:04 +00:00
|
|
|
|
$sql = 'select type_id, types from contact_types order by type';
|
|
|
|
|
|
$smarty->assign('contact_types',$db->getAssoc($sql));
|
2005-12-04 17:56:06 +00:00
|
|
|
|
|
2006-03-22 17:30:04 +00:00
|
|
|
|
$sql = 'select contact_id, name, email, contact_type_id
|
2006-10-01 20:03:00 +00:00
|
|
|
|
from contacts where contact_id='.$contact_id;
|
2005-12-04 17:56:06 +00:00
|
|
|
|
$smarty->assign('contact',$db->getRow($sql));
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
O<> le template pourrait <20>tre celui-ci. Notez l'utilisation du modificateur
|
|
|
|
|
|
<link linkend="language.modifier.truncate"><varname>truncate</varname></link>.
|
2005-12-04 17:56:06 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<select name="type_id">
|
|
|
|
|
|
<option value='null'>-- none --</option>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
{html_options options=$contact_types|truncate:20 selected=$contact.type_id}
|
2005-12-04 17:56:06 +00:00
|
|
|
|
</select>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
2006-10-01 20:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
<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>
|
2005-12-04 17:56:06 +00:00
|
|
|
|
|
2004-04-13 15:43:47 +00:00
|
|
|
|
<!-- 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
|
2005-12-04 17:56:06 +00:00
|
|
|
|
-->
|