Smarty3 中文手冊
?
# Smarty - the compiling PHP template engine
by Monte Ohrt <monte@ispi.net> and Uwe Tews<uwe dot tews at googlemail dot com>
Publication date 2010-11-11
Copyright ? 2001-2010 New Digital Group,Inc.
**Table of Contents [內容列表]**[Preface](#) [序][Preface to Translation](#) [譯序]I. [Getting Started](#) [開始]1. [What is Smarty?](#) [什么是Smaty?]2. [Installation](#) [安裝][Requirements](#) [要求][Basic Installation](#) [基本安裝][Extended Setup](#) [擴展設置]II. [Smarty For Template Designers](#) [模板設計者篇]3. [Basic Syntax](#) [基本語法][Comments](#) [注釋][Variables](#) [變量][Functions](#) [函數][Attributes](#) [屬性][Embedding Vars in Double Quotes](#) [雙引號里嵌入變量][Math](#) [數學運算][Escaping Smarty Parsing](#) [忽略Smarty解析]4. [Variables](#) [變量][Variables assigned from PHP](#) [從PHP分配的變量][Associative arrays](#) [關聯數組] [Array indexes](#) [數組索引] [Objects](#) [對象] [Variable scopes](#) [變量范圍] [Variables loaded from config files](#) [從配置文件讀取的變量][{$smarty} reserved variable](#) [{$smarty}保留變量][Request variables](#)[{$smarty.now}](#)[{$smarty.const}](#)[{$smarty.capture}](#)[{$smarty.config}](#)[{$smarty.section}](#)[{$smarty.template}](#)[{$smarty.current_dir} ](#)[{$smarty.version}](#)[{$smarty.block.child} ](#)[{$smarty.block.parent} ](#)[{$smarty.ldelim}, {$smarty.rdelim}](#)5. [Variable Modifiers](#) [變量調節器][capitalize](#) [首字符大寫][cat](#) [連接字符串][count_characters](#) [字符計數][count_paragraphs](#) [計算段數][count_sentences](#) [計算句數][count_words](#) [計算詞數][date_format](#) [格式化日期][default](#) [默認值][escape](#) [轉義][indent](#) [縮進][lower](#) [小寫][nl2br](#) [換行符替換成 <br />][regex_replace](#) [正則替換][replace](#) [替換][spacify](#) [插空][string_format](#) [字符串格式化][strip](#) [去除(多余空格)][strip_tags](#) [去除html標簽][truncate](#) [截取][upper](#) [大寫][wordwrap](#) [行寬約束]6. [Combining Modifiers](#) [組合調節器]7. [Built-in Functions](#) [內置函數][{$var=} ](#)[{append}](#)[{assign}](#)[{block}](#)[{call}](#)[{capture}](#)[{config_load}](#)[{debug}](#)[{extends}](#)[{for}](#)[{foreach},{foreachelse}](#)[{function}](#)
[{if},{elseif},{else}](#)[{include}](#)[{include_php}](#)[{insert}](#)[{ldelim},{rdelim}](#)[{literal}](#)[{nocache}](#)[{php}](#)[{section},{sectionelse}](#)[{while}](#)8. [Custom Functions](#) [自定義函數][{counter}](#)[{cycle}](#)[{eval}](#)[{fetch}](#)[{html_checkboxes}](#)[{html_image}](#)[{html_options}](#)[{html_radios}](#)[{html_select_date}](#)[{html_select_time}](#)[{html_table}](#)[{mailto}](#)[{math}](#)[{textformat}](#)9. [Config Files](#) [配置文件]10. [Debugging Console](#) [調試控制臺]III. [Smarty For Programmers](#) [程序員篇]11. [Constants](#) [常量][SMARTY_DIR](#) [Smarty目錄] 12. [Smarty Class Variables](#) [smarty類變量] [$template_dir](#) [模板目錄變量][$compile_dir](#) [編譯目錄變量][$config_dir](#) [配置目錄變量][$plugins_dir](#) [插件目錄變量][$debugging](#) [調試變量][$debug_tpl](#) [調試模板][$debugging_ctrl](#) [調試控制變量][$auto_literal](#) [自動忽略解析][$autoload_filters](#) [自動加載過濾器變量][$compile_check](#) [編譯檢查變量][$force_compile](#) [強迫編譯變量][$caching](#) [緩存變量][$cache_dir](#) [緩存目錄變量][$cache_lifetime](#) [緩存生存周期變量][$cache_handler_func](#) [緩存處理函數變量][$cache_modified_check](#) [緩存修改檢查變量][$config_overwrite](#) [配置.覆蓋變量][$config_booleanize](#) [配置.布爾型變量][$config_read_hidden](#) [配置.讀取隱藏變量][$config_fix_newlines](#) [配置.固定換行符變量][$default_template_handler_func](#) [默認模板處理函數變量][$php_handling](#) [php處理變量][$trusted_dir](#) [信任目錄變量][$left_delimiter](#) [左定界符變量][$right_delimiter](#) [右定界符變量][$compiler_class](#) [編譯類變量][$request_vars_order](#) [變量順序變量][$request_use_auto_globals](#) [自動全局變量][$compile_id](#) [編譯id變量][$use_sub_dirs](#) [子目錄變量][$default_modifiers](#) [默認調節器變量][$default_resource_type](#) [默認源類型變量]13. [Smarty Class Methods()](#) [Smarty類方法][append()](#) [添加][appendByRef()](#) [引用添加][assign()](#) [賦值][assignByRef()](#) [引用賦值][clearAllAssign()](#) [清除所有賦值][clearAllCache()](#) [清除所有緩存][clearAssign()](#) [清除賦值][clearCache()](#) [清除緩存][clearCompiledTpl()](#) [清除已編譯模板][clearConfig()](#) [清除配置][compileAllConfig()](#) [編譯所有配置][compileAllTemplates()](#) [編譯所有模板][configLoad()](#) [加載配置][createData()](#) [建立數據對象][createTemplate()](#) [建立模板對象][disableSecurity()](#) [關閉安全][display()](#) [顯示][enableSecurity()](#) [開啟安全][fetch()](#) [獲取輸出內容][getConfigVars()](#) [獲取配置變量值][getRegisteredObject()](#) [獲取已注冊的對象][getTags()](#) [獲取標簽][getTemplateVars()](#) [獲取模板變量的值][isCached()](#) [是否已被緩存][loadFilter()](#) [加載過濾器][registerFilter() ](#)[注冊過濾器][registerPlugin()](#) [注冊插件][registerObject()](#) [注冊對象][registerResource()](#) [注冊資源][templateExists()](#) [模板是否存在][unregisterFilter()](#) [注銷過濾器][unregisterPlugin()](#) [注銷插件][unregisterObject()](#) [注銷對象][unregisterResource()](#) [注銷資源][testInstall()](#) [安裝測試]14. [Caching](#) [緩存][Setting Up Caching](#) [建立緩存][Multiple Caches Per Page](#) [多重緩存][Cache Groups](#) [緩存集合][Controlling Cacheability of Plugins' Output](#) [控制插件輸出的可緩存性]15. [Advanced Features](#) [高級特性][Security](#) [安全][Changing settings by template](#) [通過模板更改設置][Template Inheritance](#) [模板繼承][Streams](#) [數據流][Objects](#) [對象][Static Classes](#) [靜態類][Prefilters](#) [預過濾器][Postfilters](#) [后過濾器][Output Filters](#) [輸出過濾器][Cache Handler Function](#) [緩存處理函數][Resources](#) [資源][Templates from $template_dir](#) [$template_dir定義的模板][Templates from any directory](#) [從任何目錄導入的模板][Templates from strings](#) [字符串定義的模板][Template inheritance defined by PHP script](#) [php定義的模板繼承][Templates from other sources](#) [從其它資源引入的模板][Default template handler function](#) [默認模板處理函數]16. [Extending Smarty With Plugins](#) [以插件擴展Smarty][How Plugins Work](#) [插件如何工作][Naming Conventions](#) [命名約定][Writing Plugins](#) [編寫插件][Template Functions](#) [模板函數][Modifiers](#) [調節器][Block Functions](#) [塊函數][Compiler Functions](#) [編譯函數][Prefilters/Postfilters](#) [預濾器/后濾器][Output Filters](#) [輸出過濾器][Resources](#) [資源][Inserts](#) [插入]IV. [Appendixes](#) [附錄]17. [Troubleshooting](#) [疑難解答][Smarty/PHP errors](#) [Smarty/PHP 錯誤]18. [Tips & Tricks](#) [使用技巧和經驗][Blank Variable Handling](#) [空白變量處理][Default Variable Handling](#) [默認變量處理][Passing variable title to header template](#) [傳遞變量標題給頭模板][Dates](#) [日期][WAP/WML](#)[Componentized Templates](#) [組件化模板][Obfuscating E-mail Addresses](#) [拒絕電子郵件地址]19. [Resources](#) [相關資源]20. [BUGS](#) [漏洞]21. [Smarty3.0.x Installation Package](#) [3.0安裝包][SMARTY2_BC_NOTES](#) [2.x版本升級至3.x版本的提示][README](#) [3.0.x使用指南]22. [LIST](#) 翻譯人員列表
| ? | ? | [Next](#) |
|-----|-----|-----|
| ? | ? | Preface |
- Smarty模板編譯引擎
- 序
- 譯序
- I.開始
- 第一章. 什么是Smarty?
- 第二章. 安裝
- II.模板設計者篇
- 第三章.基本語法
- 注釋
- 變量
- 函數
- 屬性
- 雙引號里嵌入變量
- 數學運算
- 忽略Smarty解析
- 第四章.變量
- 從PHP分配的變量
- 從配置文件讀取的變量
- 變量范圍
- {$smarty}保留變量
- 第五章.變量調節器
- capitalize
- cat
- count_characters
- count_paragraphs
- count_sentences
- count_words
- date_format
- default
- escape
- indent
- lower
- nl2br
- regex_replace
- replace
- spacify
- string_format
- strip
- strip_tags
- truncate
- upper
- wordwrap
- 第六章.組合修改器
- 第七章.內置函數
- {$var=}
- {append}
- {assign}
- {block}
- {call}
- {capture}
- {config_load}
- {debug}
- {extends}
- {for}
- {foreach},{foreachelse}
- @index
- {function}
- {if},{elseif},{else}
- {include}
- {include_php}
- {insert}
- {ldelim},{rdelim}
- {literal}
- {nocache}
- {php}
- {section},{sectionelse}
- .index
- {while}
- 第八章.自定義函數
- {counter}
- {cycle}
- {eval}
- {fetch}
- {html_checkboxes}
- {html_image}
- {html_options}
- {html_radios}
- {html_select_date}
- {html_select_time}
- {html_table}
- {mailto}
- {math}
- {textformat}
- 第九章.配置文件
- 第十章.調試控制臺
- III.模板程序員篇
- 第十一章 常量
- SMARTY_DIR
- 第十二章 Smarty類變量
- $template_dir
- 第十三章.Smarty類方法
- append()
- appendByRef()
- assign()
- assignByRef()
- clearAllAssign()
- clearAllCache()
- clearAssign()
- clearCache()
- clearCompiledTpl()
- clearConfig()
- compileAllConfig()
- compileAllTemplates()
- configLoad()
- createData()
- createTemplate()
- disableSecurity()
- display()
- enableSecurity()
- fetch()
- getConfigVars()
- getRegisteredObject()
- getTags()
- getTemplateVars()
- isCached()
- loadFilter()
- registerFilter()
- registerPlugin()
- registerObject()
- registerResource()
- templateExists()
- unregisterFilter()
- unregisterPlugin()
- unregisterObject()
- unregisterResource()
- testInstall()
- 第十四章.緩存
- 建立緩存
- 多重緩存
- 緩存集合
- 控制插件輸出的可緩存性
- 第十五章.高級特性
- 安全
- 通過模板更改設置
- 模板繼承
- 數據流
- 對象
- 靜態類
- 預過濾器
- 后過濾器
- 輸出過濾器
- 緩存處理函數
- 資源
- 第十六章.以插件擴展Smarty
- 插件如何工作
- 命名約定
- 編寫插件
- 模板函數
- 調節器
- 塊函數
- 編譯函數
- 預濾器/后濾器
- 輸出過濾器
- 資源
- 插入
- Ⅳ.附錄
- 第十七章.疑難解答
- Smarty/PHP 錯誤
- 第十八章.使用技巧和經驗
- 空白變量處理
- 默認變量處理
- 傳遞變量標題給頭模板
- 日期
- WAP/WML
- 組件化模板
- 拒絕電子郵件地址
- 第十九章. 相關資源
- 第二十章. 漏洞
- 3.0安裝包
- 2.x版本升級至3.x版本的提示
- 3.0.x使用指南
- 翻譯人員列表