Files
smarty/docs/en/programmers/plugins/plugins-inserts.xml

75 lines
2.0 KiB
XML
Raw Normal View History

2004-04-13 11:47:32 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="plugins.inserts"><title>Inserts</title>
<para>
Insert plugins are used to implement functions that are invoked by
<link linkend="language.function.insert"><command>insert</command></link>
tags in the template.
</para>
<funcsynopsis>
<funcprototype>
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
<paramdef>array <parameter>$params</parameter></paramdef>
<paramdef>object <parameter>&amp;$smarty</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
The first parameter to the function is an associative array of
attributes passed to the insert.
</para>
<para>
The insert function is supposed to return the result which will be
substituted in place of the <command>insert</command> tag in the
template.
</para>
<example>
<title>insert plugin</title>
<programlisting role="php">
<![CDATA[
<?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;
}
?>
]]>
2004-04-14 15:53:39 +00:00
</programlisting>
2004-04-13 11:47:32 +00:00
</example>
2004-04-14 15:53:39 +00:00
</sect1>
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-04-14 15:53:39 +00:00
-->