mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-06 07:11:37 +01:00
70 lines
2.6 KiB
XML
70 lines
2.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.1 Maintainer: nobody Status: ready -->
|
|
<sect1 id="api.register.function">
|
|
<title>register_function</title>
|
|
<funcsynopsis>
|
|
<funcprototype>
|
|
<funcdef>void <function>register_function</function></funcdef>
|
|
<paramdef>string <parameter>name</parameter></paramdef>
|
|
<paramdef>mixed <parameter>impl</parameter></paramdef>
|
|
<paramdef>bool <parameter>cacheable</parameter></paramdef>
|
|
<paramdef>array or null <parameter>cache_attrs</parameter></paramdef>
|
|
</funcprototype>
|
|
</funcsynopsis>
|
|
<para>
|
|
Use isso para registrar funções de plugins dinamicamente para o template.
|
|
Passe no template o nome da função,
|
|
seguido pelo nome da função PHP que implemente isso.
|
|
</para>
|
|
<para>
|
|
A chamada para função-php <parameter>impl</parameter> pode ser (a)
|
|
uma string contendo o nome da função ou (b) um array no formato
|
|
<literal>array(&$object, $method)</literal> com
|
|
<literal>&$object</literal> sendo uma referência para um
|
|
objeto e <literal>$method</literal> sendo uma string
|
|
contendo o nome do método ou (c) um array no formato
|
|
<literal>array(&$class, $method)</literal> com
|
|
<literal>$class</literal> sendo um nome de classe e
|
|
<literal>$method</literal> sendo um método
|
|
desta classe.
|
|
</para>
|
|
<para>
|
|
<parameter>$cacheable</parameter> e <parameter>$cache_attrs</parameter> podem ser omitidos na maioria dos casos. Veja <link linkend="caching.cacheable">Controlando modos de Saída Cache dos Plugins</link> para obter informações apropriadas.
|
|
</para>
|
|
<example>
|
|
<title>register_function</title>
|
|
<programlisting>
|
|
$smarty->register_function("date_now", "print_current_date");
|
|
|
|
function print_current_date ($params) {
|
|
extract($params);
|
|
if(empty($format))
|
|
$format="%b %e, %Y";
|
|
return strftime($format,time());
|
|
}
|
|
|
|
// agora você pode usar isso no Smarty para mostrar a data atual: {date_now}
|
|
// ou, {date_now format="%Y/%m/%d"} para formatar isso.</programlisting>
|
|
</example>
|
|
</sect1>
|
|
<!-- 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
|
|
--> |