Files
smarty/docs/ru/programmers/api-functions/api-display.xml
tony2001 64e51b0e1e multiple ws fixes
added EN-Revision tags everywhere
2004-07-19 13:11:36 +00:00

108 lines
3.3 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="windows-1251"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1.1 Maintainer: tony2001 Status: ready -->
<sect1 id="api.display">
<title>display</title>
<methodsynopsis>
<type>void</type><methodname>display</methodname>
<methodparam><type>string</type><parameter>template</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
</methodsynopsis>
<para>
Функция отоброжает шаблон. Укажите верный тип<link
linkend="template.resources">template resource</link>
и путь. В качестве необязательного второго параметра,
вы можете передать cache id. Смотрите <link linkend="caching">раздел
"Кэширование"</link> для дополнительной информации.
</para>
<para>
В качестве необязательного третьего параметра, можно
передать compile id. Это необходимо в том случае, если
вы хотите скомпилировать разные версии одного и того
же шаблона, например для того, чтобы иметь различные
откомпилированные версии шаблона для различных языков.
Также, compile_id может быть полезен в том случае, если
более чем один $template_dir но только один $compile_dir.
В таком случае, установите различные compile_id для каждого
$template_dir, иначе, шаблоны, имеющие одинаковые номера
перезапишут друг друга. Также, вы можете установить переменную
<link linkend="variable.compile.id">$compile_id</link> однажды,
вместо того, чтобы передавать ее при каждом вызове display().
</para>
<example>
<title>display</title>
<programlisting>
<![CDATA[
include("Smarty.class.php");
$smarty = new Smarty;
$smarty->caching = true;
// обращаемся к базе только в случае отсутствия кэша
if(!$smarty->is_cached("index.tpl"))
{
// подставляем некоторые данные
$address = "245 N 50th";
$db_data = array(
"City" => "Lincoln",
"State" => "Nebraska",
"Zip" = > "68502"
);
$smarty->assign("Name","Fred");
$smarty->assign("Address",$address);
$smarty->assign($db_data);
}
// отображаем вывод
$smarty->display("index.tpl");
]]>
</programlisting>
</example>
<para>
Используйте синтаксис <link
linkend="template.resources">template resources</link> для
отображения файлов, находящихся вне $template_dir директории.
</para>
<example>
<title>Примеры отображения шаблонов из различных ресурсов</title>
<programlisting>
<![CDATA[
// абсолютный файловый путь
$smarty->display("/usr/local/include/templates/header.tpl");
// абсолютный файловый путь (тоже самое)
$smarty->display("file:/usr/local/include/templates/header.tpl");
// абсолютный путь Windows (ОБЯЗАТЕЛЬНО используйте префикс "file:")
$smarty->display("file:C:/www/pub/templates/header.tpl");
// вставка из ресурса под названием "db"
$smarty->display("db:header.tpl");
]]>
</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
-->