| 148 |
lars |
1 |
\$compile\_id {#variable.compile.id}
|
|
|
2 |
=============
|
|
|
3 |
|
|
|
4 |
Persistent compile identifier. As an alternative to passing the same
|
|
|
5 |
`$compile_id` to each and every function call, you can set this
|
|
|
6 |
`$compile_id` and it will be used implicitly thereafter.
|
|
|
7 |
|
|
|
8 |
If you use the same template with different [pre- and/or
|
|
|
9 |
post-filters](#plugins.prefilters.postfilters) you must use a unique
|
|
|
10 |
`$compile_id` to keep the compiled template files separated.
|
|
|
11 |
|
|
|
12 |
For example a [prefilter](#plugins.prefilters.postfilters) that
|
|
|
13 |
localizes your templates (that is: translates language dependent parts)
|
|
|
14 |
at compile time, then you could use the current language as
|
|
|
15 |
`$compile_id` and you will get a set of compiled templates for each
|
|
|
16 |
language you use.
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
<?php
|
|
|
20 |
$smarty->compile_id = 'en';
|
|
|
21 |
?>
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
Another application would be to use the same compile directory across
|
|
|
26 |
multiple domains / multiple virtual hosts.
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
<?php
|
|
|
30 |
|
|
|
31 |
$smarty->compile_id = $_SERVER['SERVER_NAME'];
|
|
|
32 |
$smarty->compile_dir = '/path/to/shared_compile_dir';
|
|
|
33 |
|
|
|
34 |
?>
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
> **Note**
|
|
|
39 |
>
|
|
|
40 |
> In Smarty 3 a `$compile_id` is no longer required to keep templates
|
|
|
41 |
> with same name in different [`$template_dir`
|
|
|
42 |
> folders](#variable.template.dir) separated. The [`$template_dir` file
|
|
|
43 |
> path](#variable.template.dir) is encoded in the file name of compiled
|
|
|
44 |
> and cached template files.
|