2004-03-28 15:15:38 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
<!-- $Revision$ -->
|
2004-04-18 17:30:04 +00:00
|
|
|
<chapter id="config.files">
|
|
|
|
|
<title>Config Files</title>
|
|
|
|
|
<para>
|
2005-06-05 19:46:19 +00:00
|
|
|
Config files are handy for designers to manage global
|
|
|
|
|
template
|
|
|
|
|
variables from one file. One example is template colors.
|
|
|
|
|
Normally if
|
|
|
|
|
you wanted to change the color scheme of an application, you
|
|
|
|
|
would have
|
|
|
|
|
to go through each and every template file and change the
|
|
|
|
|
colors. With
|
|
|
|
|
a config file, the colors can be kept in one place, and only
|
|
|
|
|
one file
|
2004-04-18 17:30:04 +00:00
|
|
|
needs to be updated.
|
|
|
|
|
</para>
|
|
|
|
|
<example>
|
|
|
|
|
<title>Example of config file syntax</title>
|
|
|
|
|
<programlisting>
|
|
|
|
|
<![CDATA[
|
2004-03-28 15:15:38 +00:00
|
|
|
# global variables
|
|
|
|
|
pageTitle = "Main Menu"
|
|
|
|
|
bodyBgColor = #000000
|
|
|
|
|
tableBgColor = #000000
|
|
|
|
|
rowBgColor = #00ff00
|
|
|
|
|
|
|
|
|
|
[Customer]
|
|
|
|
|
pageTitle = "Customer Info"
|
|
|
|
|
|
|
|
|
|
[Login]
|
|
|
|
|
pageTitle = "Login"
|
|
|
|
|
focus = "username"
|
|
|
|
|
Intro = """This is a value that spans more
|
2004-04-18 17:30:04 +00:00
|
|
|
than one line. you must enclose
|
|
|
|
|
it in triple quotes."""
|
2004-03-28 15:15:38 +00:00
|
|
|
|
|
|
|
|
# hidden section
|
|
|
|
|
[.Database]
|
2004-11-21 02:04:01 +00:00
|
|
|
host=my.example.com
|
2004-03-28 15:15:38 +00:00
|
|
|
db=ADDRESSBOOK
|
|
|
|
|
user=php-user
|
2004-04-14 15:53:39 +00:00
|
|
|
pass=foobar
|
2004-04-18 17:30:04 +00:00
|
|
|
]]>
|
|
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
|
|
|
|
<para>
|
2005-05-23 15:43:01 +00:00
|
|
|
Values of
|
2005-06-05 19:46:19 +00:00
|
|
|
<link linkend="language.config.variables">config file
|
|
|
|
|
variables</link>
|
2005-05-23 15:43:01 +00:00
|
|
|
can be in quotes, but not necessary.
|
2005-06-05 19:46:19 +00:00
|
|
|
You can use either single or double quotes. If you have a
|
|
|
|
|
value that
|
|
|
|
|
spans more than one line, enclose the entire value with
|
|
|
|
|
triple quotes
|
|
|
|
|
("""). You can put comments into config files by any syntax
|
|
|
|
|
that is not
|
|
|
|
|
a valid config file syntax. We recommend using a <literal>
|
|
|
|
|
#</literal>
|
2004-04-18 17:30:04 +00:00
|
|
|
(hash) at the beginning of the line.
|
|
|
|
|
</para>
|
|
|
|
|
<para>
|
2005-06-05 19:46:19 +00:00
|
|
|
This config file example has two sections. Section names are
|
|
|
|
|
enclosed in
|
|
|
|
|
brackets []. Section names can be arbitrary strings not
|
|
|
|
|
containing
|
|
|
|
|
<literal>[</literal> or <literal>]</literal> symbols. The
|
|
|
|
|
four variables
|
|
|
|
|
at the top are global variables, or variables not within a
|
|
|
|
|
section.
|
|
|
|
|
These variables are always loaded from the config file. If a
|
|
|
|
|
particular
|
|
|
|
|
section is loaded, then the global variables and the
|
|
|
|
|
variables from that
|
|
|
|
|
section are also loaded. If a variable exists both as a
|
|
|
|
|
global and in a
|
|
|
|
|
section, the section variable is used. If you name two
|
|
|
|
|
variables the
|
|
|
|
|
same within a section, the last one will be used unless
|
|
|
|
|
<link linkend="variable.config.overwrite">
|
|
|
|
|
$config_overwrite</link>
|
|
|
|
|
is disabled.
|
2004-04-18 17:30:04 +00:00
|
|
|
</para>
|
|
|
|
|
<para>
|
2005-06-05 19:46:19 +00:00
|
|
|
Config files are loaded into templates with the built-in
|
|
|
|
|
function
|
2005-05-23 15:43:01 +00:00
|
|
|
<link
|
2005-06-05 19:46:19 +00:00
|
|
|
linkend="language.function.config.load"><command>
|
|
|
|
|
{config_load}</command></link>
|
|
|
|
|
(see also
|
2005-05-23 15:43:01 +00:00
|
|
|
<link
|
2005-06-05 19:46:19 +00:00
|
|
|
linkend="api.config.load"><command>config_load()</command></link> ).
|
2004-04-18 17:30:04 +00:00
|
|
|
</para>
|
|
|
|
|
<para>
|
2005-06-05 19:46:19 +00:00
|
|
|
You can hide variables or entire sections by prepending the
|
|
|
|
|
variable
|
|
|
|
|
name or section name with a period. This is useful if your
|
|
|
|
|
application
|
|
|
|
|
reads the config files and gets sensitive data from them
|
|
|
|
|
that the
|
|
|
|
|
template engine does not need. If you have third parties
|
|
|
|
|
doing template
|
|
|
|
|
editing, you can be certain that they cannot read sensitive
|
|
|
|
|
data from
|
2004-04-18 17:30:04 +00:00
|
|
|
the config file by loading it into the template.
|
|
|
|
|
</para>
|
2005-06-05 19:46:19 +00:00
|
|
|
|
|
|
|
|
<para>
|
|
|
|
|
See also
|
|
|
|
|
<link linkend="language.function.config.load">{config_load}</link>,
|
|
|
|
|
<link linkend="variable.config.overwrite">$config_overwrite</link>,
|
|
|
|
|
<link linkend="api.get.config.vars">get_config_vars()</link>,
|
|
|
|
|
<link linkend="api.clear.config">clear_config()</link>
|
|
|
|
|
and
|
|
|
|
|
<link linkend="api.config.load">config_load()</link>
|
|
|
|
|
</para>
|
|
|
|
|
|
2004-04-18 17:30:04 +00:00
|
|
|
</chapter>
|
2004-04-14 15:53:39 +00:00
|
|
|
|
2004-03-28 15:15:38 +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
|
|
|
-->
|
2005-06-05 19:46:19 +00:00
|
|
|
|