<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>$compile_id</title> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Smarty Manual"> <link rel="up" href="api.variables.html" title="Chapter 12. Smarty Class Variables"> <link rel="prev" href="variable.error.reporting.html" title="$error_reporting"> <link rel="next" href="variable.use.sub.dirs.html" title="$use_sub_dirs"> </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">$compile_id</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="variable.error.reporting.html">Prev</a> </td> <th width="60%" align="center">Chapter 12. Smarty Class Variables</th> <td width="20%" align="right"> <a accesskey="n" href="variable.use.sub.dirs.html">Next</a> </td> </tr> </table> <hr> </div> <div class="sect1" title="$compile_id"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="variable.compile.id"></a>$compile_id</h2></div></div></div> <p> Persistant compile identifier. As an alternative to passing the same <em class="parameter"><code>$compile_id</code></em> to each and every function call, you can set this <em class="parameter"><code>$compile_id</code></em> and it will be used implicitly thereafter. </p> <p> With a <em class="parameter"><code>$compile_id</code></em> you can work around the limitation that you cannot use the same <a class="link" href="variable.compile.dir.html" title="$compile_dir"><em class="parameter"><code>$compile_dir</code></em></a> for different <a class="link" href="api.variables.html#variable.template.dir" title="$template_dir"> <em class="parameter"><code>$template_dirs</code></em></a>. If you set a distinct <em class="parameter"><code>$compile_id</code></em> for each <a class="link" href="api.variables.html#variable.template.dir" title="$template_dir"><em class="parameter"><code>$template_dir</code></em> </a> then Smarty can tell the compiled templates apart by their <em class="parameter"><code>$compile_id</code></em>. </p> <p> If you have for example a <a class="link" href="plugins.prefilters.postfilters.html" title="Prefilters/Postfilters">prefilter</a> that localizes your templates (that is: translates language dependend parts) at compile time, then you could use the current language as <em class="parameter"><code>$compile_id</code></em> and you will get a set of compiled templates for each language you use. </p> <p> Another application would be to use the same compile directory across multiple domains / multiple virtual hosts. </p> <div class="example"> <a name="id3092701"></a><p class="title"><b>Example 12.6. $compile_id in a virtual host enviroment</b></p> <div class="example-contents"><pre class="programlisting"> <?php $smarty->compile_id = $_SERVER['SERVER_NAME']; $smarty->compile_dir = '/path/to/shared_compile_dir'; ?> </pre></div> </div> <br class="example-break"> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="variable.error.reporting.html">Prev</a> </td> <td width="20%" align="center"><a accesskey="u" href="api.variables.html">Up</a></td> <td width="40%" align="right"> <a accesskey="n" href="variable.use.sub.dirs.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top">$error_reporting </td> <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td> <td width="40%" align="right" valign="top"> $use_sub_dirs</td> </tr> </table> </div> </body> </html>