2004-04-13 11:47:32 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2004-12-26 17:02:12 +00:00
|
|
|
|
<!-- EN-Revision: 1.3 Maintainer: yannick Status: ready -->
|
|
|
|
|
|
<refentry id="api.register.function">
|
|
|
|
|
|
<refnamediv>
|
|
|
|
|
|
<refname>register_function</refname>
|
|
|
|
|
|
<refpurpose></refpurpose>
|
|
|
|
|
|
</refnamediv>
|
|
|
|
|
|
<refsect1>
|
|
|
|
|
|
<title />
|
|
|
|
|
|
<methodsynopsis>
|
|
|
|
|
|
<type>void</type><methodname>register_function</methodname>
|
|
|
|
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
|
|
|
|
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>bool</type><parameter>cacheable</parameter></methodparam>
|
|
|
|
|
|
<methodparam choice="opt"><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
|
|
|
|
|
</methodsynopsis>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Utilis<69>e pour d<>clarer dynamiquement des plugins de fonction
|
|
|
|
|
|
de templates. Il faut passer en param<61>tres le nom de la fonction
|
|
|
|
|
|
de templates, suivi par le 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(&$object, $method)</literal> o<>
|
|
|
|
|
|
<literal>&$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(&$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>tres <parameter>cacheable</parameter> et
|
|
|
|
|
|
<parameter>cache_attrs</parameter> peut <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>
|
|
|
|
|
|
<title>Exemple avec register_function</title>
|
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
2004-04-13 11:47:32 +00:00
|
|
|
|
$smarty->register_function("date_now", "print_current_date");
|
|
|
|
|
|
|
|
|
|
|
|
function print_current_date ($params) {
|
|
|
|
|
|
extract($params);
|
|
|
|
|
|
if(empty($format))
|
|
|
|
|
|
$format="%b %e, %Y";
|
|
|
|
|
|
echo strftime($format,time());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// vous pouvez maintenant utiliser ceci dans Smarty pour afficher
|
|
|
|
|
|
// la date actuelle : {date_now} ou {date_now format="%Y/%m/%d"}
|
2004-12-26 17:02:12 +00:00
|
|
|
|
// pour la formater
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
</refentry>
|
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
|
2004-05-23 15:50:53 +00:00
|
|
|
|
-->
|