<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="language.function.debug.bi.html" accesskey="P">Prev</a></td> <td width="50%" align="center" valign="bottom">Chapter 7. Built-in Functions[第七章.内置函数]</td> <td width="25%" align="right" valign="bottom"><a href="language.function.for.html" accesskey="N">Next</a></td></tr></table> # {extends} 继承 {extends} tags are used in child templates in template inheritance for extending parent templates. For details see section of Template Interitance. * The {extends} tag must be on the first line of the template. * If a child template extends a parent template with the {extends} tag it may contain only {block} tags. Any other template content is ignored. * Use the syntax for template resources to extend files outside of the $template_dir directory. {extends}标签用在模板继承中子模版对父模板的继承。具体的细节参考[模板继承](#)一节。 {extends}标签用在模版中的第一行; 如果子模板用{extends}标签继承父模板,那么它只能包含{block}标签(内容),其它任何模板内容都将忽略; 使用此语法为模板资源继承$template_dir目录外的文件。 **Attribute: ** | Attribute Name | Type | Required | Default | Description | |-----|-----|-----|-----|-----| | file | string | yes | *n/a* | The name of the template file which is extended | **属性: ** | 属性名 | 类型 | 是否必须 | 缺省值 | 描述 | |-----|-----|-----|-----|-----| | file | string | yes | *n/a* | 需继承的模板名 | <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"> <a name="AEN726" id="AEN726"> </a> <b><span class="PROGRAMLISTING">Example 7.26. Simple {extends} example</span><br/></b><strong>例 7-26.简单的{extends} 模板</strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre>{extends file='parent.tpl'}{extends 'parent.tpl'} {* short-hand *}</pre></td> </tr></table><p>See also Template Interitance and {block}.<br/> 参考<a href="advanced.features.tem.inheritance.html">模板继承</a>与<a href="language.function.block.html">{block}</a>。<br/></p> </div></td> </tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.function.debug.bi.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="language.function.for.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">{debug}<br/> 调试</td><td width="34%" align="center" valign="top"><a href="language.builtin.functions.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">{for}</td></tr></table>