Files
smarty/docs/fr/programmers/api-functions/api-register-block.xml
2004-12-26 17:02:12 +00:00

91 lines
2.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1.3 Maintainer: yannick Status: ready -->
<refentry id="api.register.block">
<refnamediv>
<refname>register_block</refname>
<refpurpose></refpurpose>
</refnamediv>
<refsect1>
<title />
<methodsynopsis>
<type>void</type><methodname>register_block</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
<methodparam><type>bool</type><parameter>cacheable</parameter></methodparam>
<methodparam><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
</methodsynopsis>
<para>
Utilisée pour déclarer dynamiquement des plugins de fonction
de blocs. Il faut passer en paramètre le nom de la fonction
de blocs, suivi du nom de la fonction PHP qui l'implémente.
</para>
<para>
La fonction PHP <parameter>impl</parameter> peut être soit (a) une
chaîne de caractères contenant le nom de la fonction, soit (b) un tableau
de la forme <literal>array(&amp;$object, $method)</literal>
<literal>&amp;$object</literal> est une référence à un objet et
<literal>$method</literal> est le nom de la méthode, soit (c) un
tableau de la forme <literal>array(&amp;$class, $method)</literal>
<literal>$class</literal> est le nom de la classe et
<literal>$method</literal> est une méthode de cette classe.
</para>
<para>
Les paramètre <parameter>cacheable</parameter> et
<parameter>cache_attrs</parameter> peuvent être omis dans la plupart
des cas. Voir <link
linkend="caching.cacheable">Contrôler la mise en cache des sorties des Plugins</link>
pour plus d'informations concernant cette utilisation.
</para>
<example>
<title>Exemple avec register_block</title>
<programlisting role="php">
<![CDATA[
<?php
$smarty->register_block("translate", "do_translation");
function do_translation ($params, $content, &amp;$smarty) {
if ($content) {
$lang = $params['lang'];
// fait de la traduction avec la variable $content
echo $translation;
}
}
?>
]]>
</programlisting>
<para>
Le template Smarty :
</para>
<programlisting>
<![CDATA[
{* template *}
{translate lang="br"}
Hello, world!
{/translate}
]]>
</programlisting>
</example>
</refsect1>
</refentry>
<!-- 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
-->