<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'} <html> <title>{#pageTitle#}</title> <body bgcolor="{#bodyBgColor#}"> <table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}"> <tr bgcolor="{#rowBgColor#}"> <td>First</td> <td>Last</td> <td>Address</td> </tr> </table> </body> </html> </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'} <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}"> <td>First</td> <td>Last</td> <td>Address</td> </tr> </table> </body> </html> </pre> <p> Both examples would output: </p> <pre class="screen"> <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> </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>