mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-25 18:31:38 +02:00
85 lines
2.7 KiB
XML
85 lines
2.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<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><type>bool</type><parameter>cacheable</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Use este para registrar funciones de plugins dinámicamente para
|
|
el template. Pase en el template el nombre de la función, seguido
|
|
por el nombre de la función PHP que implementa esto.
|
|
</para>
|
|
<para>
|
|
La llamada a la funcion-php <parameter>impl</parameter> puede ser
|
|
(a) una cadena conteniendo el nombre de la función o
|
|
(b) un arreglo en el formato
|
|
<literal>array(&$object, $method)</literal> con
|
|
<literal>&$object</literal> siendo una referencia para
|
|
un objeto y <literal>$method</literal> siendo una cadena
|
|
conteniendo el nombre del método o
|
|
(c) un arreglo en el formato
|
|
<literal>array(&$class, $method)</literal> con
|
|
<literal>$class</literal> siendo un nombre de clase y
|
|
<literal>$method</literal> siendo un método de esta clase.
|
|
</para>
|
|
<para>
|
|
<parameter>cacheable</parameter> y <parameter>cache_attrs</parameter>
|
|
pueden ser omitidos en la mayoria de los casos.
|
|
Vea <link linkend="caching.cacheable">Controlando modos de Salida Cache de
|
|
los Plugins</link> para obtener mayores informes.
|
|
</para>
|
|
<example>
|
|
<title>register_function</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$smarty->register_function("date_now", "print_current_date");
|
|
|
|
function print_current_date($params)
|
|
{
|
|
if(empty($params['format'])) {
|
|
$format = "%b %e, %Y";
|
|
} else {
|
|
$format = $params['format'];
|
|
return strftime($format,time());
|
|
}
|
|
}
|
|
// ahora usted puede usar eso en el Smarty para mostrar la fecha actual:
|
|
// {date_now} o, {date_now format="%Y/%m/%d"} para formatearle.
|
|
?>
|
|
]]>
|
|
</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
|
|
-->
|