Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 3ca7e0e5486da714e98ac79af09ca745 > files > 63

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

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Variables loaded from 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="language.variables.html" title="Chapter 4. Variables">
<link rel="prev" href="language.variables.html" title="Chapter 4. Variables">
<link rel="next" href="language.variables.smarty.html" title="{$smarty} reserved variable">
</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">Variables loaded from config files</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.variables.html">Prev</a> </td>
<th width="60%" align="center">Chapter 4. Variables</th>
<td width="20%" align="right"> <a accesskey="n" href="language.variables.smarty.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Variables loaded from config files">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.config.variables"></a>Variables loaded from config files</h2></div></div></div>
<p>
 Variables that are loaded from the
 <a class="link" href="config.files.html" title="Chapter 9. Config Files">config files</a>
 are referenced by enclosing them within <code class="literal">#hash marks#</code>,
 or with the smarty variable
 <a class="link" href="language.variables.smarty.html#language.variables.smarty.config" title="{$smarty.config}">
 <em class="parameter"><code>$smarty.config</code></em></a>.
  The later syntax is useful for embedding into quoted attribute values.
  </p>
<div class="example">
<a name="id3029724"></a><p class="title"><b>Example 4.6. config variables</b></p>
<div class="example-contents">
<p>
     Example config file - <code class="filename">foo.conf</code>:
    </p>
<pre class="programlisting">

pageTitle = "This is mine"
bodyBgColor = '#eeeeee'
tableBorderSize = 3
tableBgColor = "#bbbbbb"
rowBgColor = "#cccccc"

    </pre>
<p>
     A template demonstrating the <em class="parameter"><code>#hash#</code></em> method:
    </p>
<pre class="programlisting">

{config_load file='foo.conf'}
&lt;html&gt;
&lt;title&gt;{#pageTitle#}&lt;/title&gt;
&lt;body bgcolor="{#bodyBgColor#}"&gt;
&lt;table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}"&gt;
&lt;tr bgcolor="{#rowBgColor#}"&gt;
    &lt;td&gt;First&lt;/td&gt;
    &lt;td&gt;Last&lt;/td&gt;
    &lt;td&gt;Address&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

    </pre>
<p>
     A template demonstrating the
     <a class="link" href="language.variables.smarty.html#language.variables.smarty.config" title="{$smarty.config}">
     <em class="parameter"><code>$smarty.config</code></em></a> method:
    </p>
<pre class="programlisting">

{config_load file='foo.conf'}
&lt;html&gt;
&lt;title&gt;{$smarty.config.pageTitle}&lt;/title&gt;
&lt;body bgcolor="{$smarty.config.bodyBgColor}"&gt;
&lt;table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}"&gt;
&lt;tr bgcolor="{$smarty.config.rowBgColor}"&gt;
    &lt;td&gt;First&lt;/td&gt;
    &lt;td&gt;Last&lt;/td&gt;
    &lt;td&gt;Address&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

    </pre>
<p>
     Both examples would output:
    </p>
<pre class="screen">

&lt;html&gt;
&lt;title&gt;This is mine&lt;/title&gt;
&lt;body bgcolor="#eeeeee"&gt;
&lt;table border="3" bgcolor="#bbbbbb"&gt;
&lt;tr bgcolor="#cccccc"&gt;
	&lt;td&gt;First&lt;/td&gt;
	&lt;td&gt;Last&lt;/td&gt;
	&lt;td&gt;Address&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

    </pre>
</div>
</div>
<br class="example-break"><p>
  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
  <a class="link" href="language.function.config.load.html" title="{config_load}">
  <code class="varname">{config_load}</code></a>.
</p>
<p>
  See also <a class="link" href="language.syntax.variables.html" title="Variables">variables</a> and
  <a class="link" href="language.variables.smarty.html" title="{$smarty} reserved variable">$smarty reserved
  variables</a>
</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.variables.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.variables.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.variables.smarty.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 4. Variables </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> {$smarty} reserved variable</td>
</tr>
</table>
</div>
</body>
</html>