?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
Smarty comes with several built-in functions. Built-in functions are integral to the template language. You cannot create custom functions with the same names, nor can you modify built-in functions.
Smarty自帶一些內(nèi)建函數(shù).
內(nèi)建函數(shù)是模板語言的一部分.
用戶不能創(chuàng)建名稱和內(nèi)建函數(shù)一樣的自定義函數(shù),也不能修改內(nèi)建函數(shù).
Attribute Name | Type | Required | Default | Description |
---|---|---|---|---|
name | string | no | default | The name of the captured block |
assign | string | No | n/a | The variable name where to assign the captured output to |
屬性 | 類型 | 是否必須 | 缺省值 | 描述 |
---|---|---|---|---|
name | string | no | default | 數(shù)據(jù)采集區(qū)域名稱 |
assign | string | No | n/a | 數(shù)據(jù)采集區(qū)域在哪分配給變量name[待考] |
capture is used to collect the output of the template into a variable instead of displaying it. Any content between {capture name="foo"} and {/capture} is collected into the variable specified in the name attribute. The captured content can be used in the template from the special variable $smarty.capture.foo where foo is the value passed in the name attribute. If you do not supply a name attribute, then "default" will be used. All {capture} commands must be paired with {/capture}. You can nest capture commands.
capture函數(shù)的作用是捕獲模板輸出的數(shù)據(jù)并將其存儲到一個變量里,而不是把它們輸出到頁面.
任何在 {capture name="foo"}和{/capture}之間的數(shù)據(jù)將被存儲到變量$foo中,該變量由name屬性指定.
在模板中通過 $smarty.capture.foo 訪問該變量.
如果沒有指定 name 屬性,函數(shù)默認(rèn)將使用 "default" 作為參數(shù).
{capture}必須成對出現(xiàn),即以{/capture}作為結(jié)尾,該函數(shù)不能嵌套使用.
Technical Note: Smarty 1.4.0 - 1.4.4 placed the captured content into the variable named $return. As of 1.4.5, this behavior was changed to use the name attribute, so update your templates accordingly.
技術(shù)提示:
Smarty 1.4.0 - 1.4.4 版把捕獲到的內(nèi)容存儲于 $return 變量里.
在 1.4.5 版以后就將該數(shù)據(jù)保存到了由 name 屬性指定的變量里.請升級你的模板.
Caution |
Be careful when capturing {insert} output. If you have caching turned on and you have {insert} commands that you expect to run within cached content, do not capture this content. |
警告 |
當(dāng)希望捕獲包含 {insert} 命令的數(shù)據(jù)時要特別注意. 如果打開了緩存并希望將 {insert} 命令輸出到緩存中,不要捕獲該區(qū)域的數(shù)據(jù). |
Example 7-1. capturing template content
|