Files
smarty/docs/id/designers/language-variables/language-config-variables.xml
2008-12-23 20:32:55 +00:00

120 lines
3.0 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision$ -->
<sect1 id="language.config.variables">
<title>Variabel yang diambil dari file config</title>
<para>
Variabel yang diambil dari <link linkend="config.files">file config</link>
direferensi dengan menutupinya dalam <literal>#tanda kris#</literal>,
atau dengan variabel smarty <link linkend="language.variables.smarty.config">
<parameter>$smarty.config</parameter></link>.
Sintaks terakhir berguna untuk menyertakan ke dalam nilai atribut bertanda
kutip.
</para>
<example>
<title>variabel config</title>
<para>
Contoh file config - <filename>foo.conf</filename>:
</para>
<programlisting>
<![CDATA[
pageTitle = "This is mine"
bodyBgColor = '#eeeeee'
tableBorderSize = 3
tableBgColor = "#bbbbbb"
rowBgColor = "#cccccc"
]]>
</programlisting>
<para>
Template yang memperlihatkan metode <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>
Template yang memperlihatkan metode
<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>
Kedua contoh akan menampilkan:
</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>
Variabel file config tidak bisa dipakai sampai setelah diambil dari file
config. Prosedur ini dijelaskan nanti dalam dokumen ini di bawah
<link linkend="language.function.config.load">
<varname>{config_load}</varname></link>.
</para>
<para>
Lihat juga <link linkend="language.syntax.variables">variabel</link> dan
<link linkend="language.variables.smarty">variabel terpakai $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
-->