Files
smarty/docs/en/designers/language-variables/language-config-variables.xml

123 lines
3.0 KiB
XML
Raw Normal View History

2004-04-13 08:46:28 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.config.variables">
2006-09-26 03:44:02 +00:00
<title>Variables loaded from config files</title>
<para>
Variables that are loaded from the
<link linkend="config.files">config files</link>
2006-09-26 03:44:02 +00:00
are referenced by enclosing them within <literal>#hash marks#</literal>,
or with the smarty variable
<link linkend="language.variables.smarty.config">
<parameter>$smarty.config</parameter></link>.
The later syntax is useful for embedding into quoted attribute values.
</para>
2004-04-13 08:46:28 +00:00
<example>
<title>config variables</title>
<para>
2006-09-26 03:44:02 +00:00
Example config file - <filename>foo.conf</filename>:
2004-04-13 08:46:28 +00:00
</para>
<programlisting>
<![CDATA[
pageTitle = "This is mine"
2006-09-26 03:44:02 +00:00
bodyBgColor = '#eeeeee'
tableBorderSize = 3
2004-04-13 08:46:28 +00:00
tableBgColor = "#bbbbbb"
rowBgColor = "#cccccc"
]]>
</programlisting>
<para>
2006-09-26 03:44:02 +00:00
A template demonstrating the <parameter>#hash#</parameter> method:
2004-04-13 08:46:28 +00:00
</para>
<programlisting>
<![CDATA[
2006-09-26 03:44:02 +00:00
{config_load file='foo.conf'}
2004-04-13 08:46:28 +00:00
<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
<tr bgcolor="{#rowBgColor#}">
2006-09-26 03:44:02 +00:00
<td>First</td>
<td>Last</td>
<td>Address</td>
2004-04-13 08:46:28 +00:00
</tr>
</table>
</body>
</html>
]]>
</programlisting>
<para>
2006-09-26 03:44:02 +00:00
A template demonstrating the
<link linkend="language.variables.smarty.config">
<parameter>$smarty.config</parameter></link> method:
2004-04-13 08:46:28 +00:00
</para>
<programlisting>
<![CDATA[
2006-09-26 03:44:02 +00:00
{config_load file='foo.conf'}
2004-04-13 08:46:28 +00:00
<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}">
2006-09-26 03:44:02 +00:00
<td>First</td>
<td>Last</td>
<td>Address</td>
2004-04-13 08:46:28 +00:00
</tr>
</table>
</body>
</html>
]]>
</programlisting>
<para>
2006-09-26 03:44:02 +00:00
Both examples would output:
2004-04-13 08:46:28 +00:00
</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>
2005-05-27 16:25:02 +00:00
<para>
Config file variables cannot be used until
after they are loaded in from a config file. This procedure is
explained later in this document under
2006-09-26 03:44:02 +00:00
<link linkend="language.function.config.load">
<varname>{config_load}</varname></link>.
2005-05-27 16:25:02 +00:00
</para>
<para>
See also <link linkend="language.syntax.variables">variables</link> and
2005-05-27 16:25:02 +00:00
<link linkend="language.variables.smarty">$smarty reserved
variables</link>
</para>
2004-04-13 08:46:28 +00:00
</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
2005-05-27 16:25:02 +00:00
-->