Files
smarty/docs/ru/programmers/plugins/plugins-inserts.xml
2008-05-25 15:06:11 +00:00

77 lines
2.5 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 0 Maintainer: tony2001 Status: ready -->
<sect1 id="plugins.inserts">
<title>Вставки</title>
<para>
Плагины вставок используются для исполнения функций, вызываемых тэгом
<link linkend="language.function.insert"><command>insert</command></link>
в шаблоне.
</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>
Первый параметр функции представляет собой ассоциативный массив атрибутов,
переданых для вставки. Доступ к этим значениям можно получить как напрямую:
т.е. <varname>$params['start']</varname> так и используя
<varname>extract($params)</varname> для импорта.
</para>
<para>
Функция вставки возвращает результат, которым будет
заменен тэг <command>insert</command> в шаблоне.
</para>
<example>
<title>Плагин вставки</title>
<programlisting role="php">
<![CDATA[
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Файл: insert.time.php
* Тип: time
* Имя: time
* Назначение: Вставка текущей даты/времени в определенном формате
* -------------------------------------------------------------
*/
function smarty_insert_time($params, &amp;$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
-->