| 148 |
lars |
1 |
Extends Template Resources {#resources.extends}
|
|
|
2 |
==========================
|
|
|
3 |
|
|
|
4 |
The `extends:` resource is used to define child/parent relationships for
|
|
|
5 |
template inheritance from the PHP script. For details see section of
|
|
|
6 |
[Template Inheritance](#advanced.features.template.inheritance).
|
|
|
7 |
|
|
|
8 |
As of Smarty 3.1 the `extends:` resource may use any available [template
|
|
|
9 |
resource](#resources), including `string:` and `eval:`. When [templates
|
|
|
10 |
from strings](#resources.string) are used, make sure they are properly
|
|
|
11 |
(url or base64) encoded. Is an `eval:` resource found within an
|
|
|
12 |
inheritance chain, its \"don\'t save a compile file\" property is
|
|
|
13 |
superseded by the `extends:` resource. The templates within an
|
|
|
14 |
inheritance chain are not compiled separately, though. Only a single
|
|
|
15 |
compiled template will be generated.
|
|
|
16 |
|
|
|
17 |
> **Note**
|
|
|
18 |
>
|
|
|
19 |
> Use this when inheritance is required programmatically. When inheriting
|
|
|
20 |
> within PHP, it is not obvious from the child template what inheritance
|
|
|
21 |
> took place. If you have a choice, it is normally more flexible and
|
|
|
22 |
> intuitive to handle inheritance chains from within the templates.
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
<?php
|
|
|
26 |
$smarty->display('extends:parent.tpl|child.tpl|grandchild.tpl');
|
|
|
27 |
|
|
|
28 |
// inheritance from multiple template sources
|
|
|
29 |
$smarty->display('extends:db:parent.tpl|file:child.tpl|grandchild.tpl|eval:{block name="fooBazVar_"}hello world{/block}');
|
|
|
30 |
?>
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
See also [Template Inheritance](#advanced.features.template.inheritance)
|
|
|
35 |
[`{block}`](#language.function.block) and
|
|
|
36 |
[`{extends}`](#language.function.extends).
|