mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-03 13:51:36 +01:00
97 lines
3.1 KiB
XML
97 lines
3.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.5 Maintainer: yannick Status: ready -->
|
|
|
|
<refentry id="api.register.block">
|
|
<refnamediv>
|
|
<refname>register_block()</refname>
|
|
<refpurpose>Déclare dynamiquement des plugins de fonction de blocs</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</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 <link linkend="plugins.block.functions">plugins de fonction
|
|
de blocs</link>. 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(&$object, $method)</literal> où
|
|
<literal>&$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(&$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è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, &$smarty, &$repeat) {
|
|
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>
|
|
<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>
|
|
</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
|
|
--> |