Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

{extends}

模板继承中,你可以在子模板内使用{extends}标签来扩展父模板。 详细参见模板继承.

  • {extends}必须放在模板的第一行。

  • 如果子模板要用{extends}来扩展父模板,那么它只能有 {block}的区域。任何其他的模板内容都会被忽略。

  • 扩展使用在$template_dir 之外的文件,请使用模板资源的语法。

Note

当你扩展一个父模板名称的变量如{extends file=$parent_file}, 请确保$parent_file变量放到同一个 $cache_id中. 否则Smarty无法辨别不同的$parent_file变量。

属性:

参数名称 类型 必选参数 默认值 说明
file string Yes n/a 被扩展的模板名称

Example 7.26. 简单 {extends} 例子


{extends file='parent.tpl'}
{extends 'parent.tpl'}  {* short-hand *}

  

参见 模板继承{block}.

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors