Files
smarty/docs/fr/programmers/api-functions/api-register-block.xml

97 lines
3.1 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2005-12-05 21:15:38 +00:00
<!-- EN-Revision: 1.5 Maintainer: yannick Status: ready -->
2004-12-26 17:02:12 +00:00
<refentry id="api.register.block">
<refnamediv>
2005-12-05 21:15:38 +00:00
<refname>register_block()</refname>
<refpurpose>D<EFBFBD>clare dynamiquement des plugins de fonction de blocs</refpurpose>
2004-12-26 17:02:12 +00:00
</refnamediv>
<refsect1>
2005-12-05 21:15:38 +00:00
<title>Description</title>
2004-12-26 17:02:12 +00:00
<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>
2005-12-05 21:15:38 +00:00
Utilis<69>e pour d<>clarer dynamiquement des <link linkend="plugins.block.functions">plugins de fonction
de blocs</link>. Il faut passer en param<61>tre le nom de la fonction
2004-12-26 17:02:12 +00:00
de blocs, suivi du nom de la fonction PHP qui l'impl<70>mente.
</para>
<para>
La fonction PHP <parameter>impl</parameter> peut <20>tre soit (a) une
cha<68>ne de caract<63>res contenant le nom de la fonction, soit (b) un tableau
de la forme <literal>array(&amp;$object, $method)</literal> o<>
<literal>&amp;$object</literal> est une r<>f<EFBFBD>rence <20> 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> o<>
<literal>$class</literal> est le nom de la classe et
<literal>$method</literal> est une m<>thode de cette classe.
</para>
<para>
Les param<61>tre <parameter>cacheable</parameter> et
<parameter>cache_attrs</parameter> peuvent <20>tre omis dans la plupart
des cas. Voir <link
linkend="caching.cacheable">Contr<74>ler la mise en cache des sorties des Plugins</link>
pour plus d'informations concernant cette utilisation.
</para>
<example>
2005-12-05 21:15:38 +00:00
<title>Exemple avec register_block()</title>
2004-12-26 17:02:12 +00:00
<programlisting role="php">
<![CDATA[
<?php
2005-12-05 21:15:38 +00:00
$smarty->register_block('translate', 'do_translation');
2004-04-13 11:47:32 +00:00
2005-12-05 21:15:38 +00:00
function do_translation ($params, $content, &$smarty, &$repeat) {
2004-04-13 11:47:32 +00:00
if ($content) {
$lang = $params['lang'];
// fait de la traduction avec la variable $content
echo $translation;
}
}
2004-12-26 17:02:12 +00:00
?>
]]>
</programlisting>
<para>
Le template Smarty :
</para>
<programlisting>
<![CDATA[
2004-04-13 11:47:32 +00:00
{* template *}
{translate lang="br"}
2004-12-26 17:02:12 +00:00
Hello, world!
{/translate}
]]>
</programlisting>
</example>
2005-12-05 21:15:38 +00:00
<para>
Voir aussi
<link linkend="api.unregister.block">unregister_block()</link> et
les <link linkend="plugins.block.functions">plugins de fonction de blocs</link>.
</para>
2004-12-26 17:02:12 +00:00
</refsect1>
</refentry>
2005-12-05 21:15:38 +00:00
2004-04-13 11:47:32 +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-05 21:15:38 +00:00
-->