Files
smarty/docs/ja/programmers/api-functions/api-display.xml
2007-04-21 12:13:34 +00:00

117 lines
3.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 1.8 Maintainer: takagi Status: ready -->
<!-- CREDITS: mat-sh,daichi,joe -->
<refentry id="api.display">
<refnamediv>
<refname>display()</refname>
<refpurpose>テンプレートを表示します。</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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="api.fetch"><varname>fetch()</varname></link> と違い出力を行います)。
第1パラメータには、有効な <link
linkend="template.resources">テンプレートリソース</link>
の種類を含むパスを指定する事ができます。任意の第2パラメータには
<parameter>キャッシュID</parameter> を渡す事ができます。
詳細は <link linkend="caching">キャッシュの項</link> を参照してください。
</para>
&parameter.compileid;
<example>
<title>display()</title>
<programlisting role="php">
<![CDATA[
<?php
include(SMARTY_DIR.'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('data', $db_data);
}
// 出力を表示します
$smarty->display('index.tpl');
?>
]]>
</programlisting>
</example>
<example>
<title>display() 関数にテンプレートリソースを指定した例</title>
<para>
<link linkend="variable.template.dir">
<parameter>$template_dir</parameter></link> ディレクトリ外のファイルを表示するためには、
<link linkend="template.resources">テンプレートリソース</link>
を指定します。
</para>
<programlisting role="php">
<![CDATA[
<?php
// ファイルの絶対パス
$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>
<para>
<link linkend="api.fetch"><varname>fetch()</varname></link> および
<link linkend="api.template.exists"><varname>template_exists()</varname></link>
も参照してください。
</para>
</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
-->