mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-08 08:11:39 +01:00
73 lines
2.2 KiB
XML
73 lines
2.2 KiB
XML
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|||
|
|
<!-- $Revision$ -->
|
|||
|
|
<sect1 id="plugins.inserts"><title>Inserts</title>
|
|||
|
|
<para>
|
|||
|
|
Plugins Insert s<>o usados para implementar fun<75><6E>es que s<>o invocadas por tags
|
|||
|
|
<link linkend="language.function.insert"><command>insert</command></link>
|
|||
|
|
no template.
|
|||
|
|
</para>
|
|||
|
|
<funcsynopsis>
|
|||
|
|
<funcprototype>
|
|||
|
|
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
|
|||
|
|
<paramdef>array <parameter>$params</parameter></paramdef>
|
|||
|
|
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
|||
|
|
</funcprototype>
|
|||
|
|
</funcsynopsis>
|
|||
|
|
<para>
|
|||
|
|
O primeiro par<61>metro para a fun<75><6E>o <20> um array
|
|||
|
|
associativo de atributos passados para o
|
|||
|
|
insert. Ou acessa esses valores diretamente,
|
|||
|
|
i.e. <varname>$params['start']</varname> ou usa
|
|||
|
|
<varname>extract($params)</varname> para import<72>-los para dentro da tabela s<>mbolo.
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
A fun<75><6E>o insert deve retornar o
|
|||
|
|
resultado que ser<65> substitu<74>do no lugar da tag
|
|||
|
|
<command>insert</command> no template.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>Plugin insert</title>
|
|||
|
|
<programlisting>
|
|||
|
|
<?php
|
|||
|
|
/*
|
|||
|
|
* Smarty plugin
|
|||
|
|
* -------------------------------------------------------------
|
|||
|
|
* File: insert.time.php
|
|||
|
|
* Type: time
|
|||
|
|
* Name: time
|
|||
|
|
* Purpose: Inserts current date/time according to format
|
|||
|
|
* -------------------------------------------------------------
|
|||
|
|
*/
|
|||
|
|
function smarty_insert_time($params, &$smarty)
|
|||
|
|
{
|
|||
|
|
if (empty($params['format'])) {
|
|||
|
|
$smarty->trigger_error("insert time: missing 'format' parameter");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$datetime = strftime($params['format']);
|
|||
|
|
return $datetime;
|
|||
|
|
}
|
|||
|
|
?></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
|
|||
|
|
-->
|