|
1 In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags |
|
2 is done at compile time and the parent and child templates are compiled in a single compiled template. |
|
3 {include} subtemplate could also {block} tags. Such subtemplate could not compiled by it's own because |
|
4 it could be used in other context where the {block} extended with a different result. For that reasion |
|
5 the compiled code of {include} subtemplates gets also merged in compiled inheritance template. |
|
6 |
|
7 Merging the code into a single compile template has some drawbacks. |
|
8 1. You could not use variable file names in {include} Smarty would use the {include} of compilation time. |
|
9 2. You could not use individual compile_id in {include} |
|
10 3. Seperate caching of subtemplate was not possible |
|
11 4. Any change of the template directory structure between calls was not necessarily seen. |
|
12 |
|
13 Starting with 3.1.15 some of the above conditions got checked and resulted in an exception. It turned out |
|
14 that a couple of users did use some of above and now got exceptions. |
|
15 |
|
16 To resolve this starting with 3.1.16 there is a new configuration parameter $inheritance_merge_compiled_includes. |
|
17 For most backward compatibility its default setting is true. |
|
18 With this setting all {include} subtemplate will be merge into the compiled inheritance template, but the above cases |
|
19 could be rejected by exception. |
|
20 |
|
21 |
|
22 If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged. |
|
23 You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option. |
|
24 {include file='foo.bar' inline} |
|
25 |
|
26 1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo; |
|
27 2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the |
|
28 global compile_id as well $smarty->compile_id = $bar; |
|
29 3. If call templates with different template_dir configurations and a parent could same named child template from different folders |
|
30 you must make the folder name part of the compile_id. |
|
31 |
|
32 |
|
33 In the upcomming major release Smarty 3.2 inheritance will no longer be a compile time process. |
|
34 All restrictions will be then removed. |
|
35 |