mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-09 00:31:45 +01:00
122 lines
3.2 KiB
XML
122 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 2602 Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: mat-sh,daichi,joe -->
|
|
<sect1 id="language.config.variables">
|
|
<title>設定ファイルから読み込まれた変数</title>
|
|
<para>
|
|
<link linkend="config.files">設定ファイル</link>
|
|
から読み込まれた変数を参照するには、それをハッシュマーク (<literal>#</literal>)
|
|
で囲むか、あるいは Smarty 変数 <link linkend="language.variables.smarty.config">
|
|
<parameter>$smarty.config</parameter></link> を使用します。
|
|
2つ目の方法は、クォートされた属性値の中に含める場合に便利です。
|
|
</para>
|
|
<example>
|
|
<title>設定ファイルの変数</title>
|
|
<para>
|
|
サンプルの設定ファイル - <filename>foo.conf</filename>:
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
pageTitle = "This is mine"
|
|
bodyBgColor = '#eeeeee'
|
|
tableBorderSize = 3
|
|
tableBgColor = "#bbbbbb"
|
|
rowBgColor = "#cccccc"
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
<parameter>#hash#</parameter> 方式のテンプレート
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{config_load file='foo.conf'}
|
|
<html>
|
|
<title>{#pageTitle#}</title>
|
|
<body bgcolor="{#bodyBgColor#}">
|
|
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
|
<tr bgcolor="{#rowBgColor#}">
|
|
<td>First</td>
|
|
<td>Last</td>
|
|
<td>Address</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
<link linkend="language.variables.smarty.config">
|
|
<parameter>$smarty.config</parameter></link> 方式のテンプレート
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{config_load file='foo.conf'}
|
|
<html>
|
|
<title>{$smarty.config.pageTitle}</title>
|
|
<body bgcolor="{$smarty.config.bodyBgColor}">
|
|
<table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}">
|
|
<tr bgcolor="{$smarty.config.rowBgColor}">
|
|
<td>First</td>
|
|
<td>Last</td>
|
|
<td>Address</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
どちらの場合も出力は同じです。
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
<html>
|
|
<title>This is mine</title>
|
|
<body bgcolor="#eeeeee">
|
|
<table border="3" bgcolor="#bbbbbb">
|
|
<tr bgcolor="#cccccc">
|
|
<td>First</td>
|
|
<td>Last</td>
|
|
<td>Address</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<para>
|
|
変数は、設定ファイルから読み込まれるまで使用できません。
|
|
詳細は、後ほど
|
|
<link linkend="language.function.config.load">
|
|
<varname>{config_load}</varname></link>
|
|
の項で説明します。
|
|
</para>
|
|
<para>
|
|
<link linkend="language.syntax.variables">変数</link> および
|
|
<link linkend="language.variables.smarty">予約変数
|
|
$smarty</link> も参照してください。
|
|
</para>
|
|
</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
|
|
-->
|