Files
smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml

179 lines
4.6 KiB
XML
Raw Normal View History

2004-04-13 08:46:28 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2004-04-18 17:18:26 +00:00
<sect1 id="language.function.config.load">
<title>{config_load}</title>
2004-04-18 17:18:26 +00:00
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
<colspec colname="type" align="center" />
<colspec colname="required" align="center" />
<colspec colname="default" align="center" />
<colspec colname="desc" />
<thead>
<row>
<entry>Attribute Name</entry>
<entry>Type</entry>
<entry>Required</entry>
<entry>Default</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>file</entry>
<entry>string</entry>
<entry>Yes</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>The name of the config file to include</entry>
</row>
<row>
<entry>section</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>The name of the section to load</entry>
</row>
<row>
<entry>scope</entry>
<entry>string</entry>
<entry>no</entry>
<entry><emphasis>local</emphasis></entry>
<entry>
How the scope of the loaded variables are treated,
which must be one of local, parent or global. local
means variables are loaded into the local template
context. parent means variables are loaded into both
the local context and the parent template that called
it. global means variables are available to all
templates.
</entry>
</row>
<row>
<entry>global</entry>
<entry>boolean</entry>
<entry>No</entry>
<entry><emphasis>No</emphasis></entry>
<entry>
Whether or not variables are visible to the parent
template, same as scope=parent. NOTE: This attribute is
deprecated by the scope attribute, but still supported.
If scope is supplied, this value is ignored.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
{config_load} is used for loading config
<link linkend="language.config.variables">#variables#</link> from a
2005-05-27 16:25:02 +00:00
<link linkend="config.files">configuration file</link> into the template.
2004-04-18 17:18:26 +00:00
</para>
<example>
<title>{config_load}</title>
2005-05-27 16:25:02 +00:00
<para>
example.conf
</para>
2004-04-18 17:18:26 +00:00
<programlisting>
2004-04-14 15:53:39 +00:00
<![CDATA[
2005-05-27 16:25:02 +00:00
#this is config file comment
# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00
#customer variables section
[Customer]
pageTitle = "Customer Info"
]]>
</programlisting>
<para>and the template</para>
<programlisting>
<![CDATA[
{config_load file="example.conf"}
2004-04-13 08:46:28 +00:00
2004-04-14 15:53:39 +00:00
<html>
2005-05-27 16:25:02 +00:00
<title>{#pageTitle#|default:"No title"}</title>
2004-04-14 15:53:39 +00:00
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
2004-04-18 17:18:26 +00:00
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
2004-04-14 15:53:39 +00:00
</table>
</body>
</html>
]]>
2004-04-18 17:18:26 +00:00
</programlisting>
</example>
<para>
<link linkend="config.files">Config Files</link>
may also contain sections. You can load variables from
2004-04-18 17:18:26 +00:00
within a section with the added attribute
2005-05-27 16:25:02 +00:00
<emphasis>'section'</emphasis>.
2004-04-18 17:18:26 +00:00
</para>
2004-04-18 17:23:26 +00:00
<note>
<para>
<emphasis>Config file sections</emphasis> and the built-in
2005-05-27 16:25:02 +00:00
template function called
<link linkend="language.function.section"><emphasis>{section}</emphasis></link>
have nothing
2004-04-18 17:23:26 +00:00
to do with each other, they just happen to share a common naming
convention.
</para>
</note>
2004-04-18 17:18:26 +00:00
<example>
2005-05-27 16:25:02 +00:00
<title>function {config_load} with section</title>
2004-04-18 17:18:26 +00:00
<programlisting>
2004-04-14 15:53:39 +00:00
<![CDATA[
2005-05-27 16:25:02 +00:00
{config_load file="example.conf" section="Customer"}
2004-04-13 08:46:28 +00:00
2004-04-14 15:53:39 +00:00
<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
2004-04-18 17:18:26 +00:00
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
2004-04-14 15:53:39 +00:00
</table>
</body>
</html>
]]>
2004-04-18 17:18:26 +00:00
</programlisting>
</example>
<para>
See also <link linkend="config.files">Config files</link>,
<link linkend="language.config.variables">Config variables</link>,
<link linkend="variable.config.dir">$config_dir</link>,
<link linkend="api.get.config.vars">get_config_vars()</link>
and
<link linkend="api.config.load">config_load()</link>.
</para>
2004-04-13 08:46:28 +00:00
</sect1>
2004-04-14 15:53:39 +00:00
2004-04-13 08:46:28 +00:00
<!-- 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
2004-04-14 15:53:39 +00:00
-->