Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 3ca7e0e5486da714e98ac79af09ca745 > files > 53

php-smarty2-doc-2.6.28-2.mga4.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 9. Config Files</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
<link rel="home" href="index.html" title="Smarty Manual">
<link rel="up" href="smarty.for.designers.html" title="Part II. Smarty For Template Designers">
<link rel="prev" href="language.function.textformat.html" title="{textformat}">
<link rel="next" href="chapter.debugging.console.html" title="Chapter 10. Debugging Console">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 9. Config Files</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.function.textformat.html">Prev</a> </td>
<th width="60%" align="center">Part II. Smarty For Template Designers</th>
<td width="20%" align="right"> <a accesskey="n" href="chapter.debugging.console.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter" title="Chapter 9. Config Files">
<div class="titlepage"><div><div><h2 class="title">
<a name="config.files"></a>Chapter 9. Config Files</h2></div></div></div>
<p>
  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 needs to be updated.
 </p>
<div class="example">
<a name="id3084196"></a><p class="title"><b>Example 9.1. Example of config file syntax</b></p>
<div class="example-contents"><pre class="programlisting">

# 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
           than one line. you must enclose
           it in triple quotes."""

# hidden section
[.Database]
host=my.example.com
db=ADDRESSBOOK
user=php-user
pass=foobar

  </pre></div>
</div>
<br class="example-break"><p>
  Values of <a class="link" href="language.config.variables.html" title="Variables loaded from config files">config file
  variables</a> can be in quotes, but not necessary.  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 <code class="literal">
  #</code> (hash) at the beginning of the line.
 </p>
<p>
  The example config file above has two sections. Section names are
  enclosed in [brackets]. Section names can be arbitrary strings not
  containing <code class="literal">[</code> or <code class="literal">]</code> 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 <a class="link" href="variable.config.overwrite.html" title="$config_overwrite">
  <em class="parameter"><code>$config_overwrite</code></em></a> is disabled.
 </p>
<p>
  Config files are loaded into templates with the built-in template function
  <a class="link" href="language.function.config.load.html" title="{config_load}"><code class="varname">
  {config_load}</code></a> or the API <a class="link" href="api.config.load.html" title="config_load()"><code class="varname">config_load()</code></a> function.
 </p>
<p>
  You can hide variables or entire sections by prepending the variable
  name or section name with a period eg <code class="literal">[.hidden]</code>. 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 the config file by loading it into the template.
 </p>
<p>
  See also
  <a class="link" href="language.function.config.load.html" title="{config_load}"><code class="varname">{config_load}</code></a>,
  <a class="link" href="variable.config.overwrite.html" title="$config_overwrite"><em class="parameter"><code>$config_overwrite</code></em></a>,
  <a class="link" href="api.get.config.vars.html" title="get_config_vars()"><code class="varname">get_config_vars()</code></a>,
  <a class="link" href="api.clear.config.html" title="clear_config()"><code class="varname">clear_config()</code></a>
  and
  <a class="link" href="api.config.load.html" title="config_load()"><code class="varname">config_load()</code></a>
 </p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.function.textformat.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="smarty.for.designers.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="chapter.debugging.console.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">{textformat} </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Chapter 10. Debugging Console</td>
</tr>
</table>
</div>
</body>
</html>