Smarty Documentation
Main Page
Constants
SMARTY_DIR
Functions
{$var=...}
{append}
{assign}
{block}
{call}
{capture}
{config_load}
{counter}
{cycle}
{debug}
{eval}
{extends}
{fetch}
{foreach},{foreachelse}
{for}
{function}
{html_checkboxes}
{html_image}
{html_options}
{html_radios}
{html_select_date}
{html_select_time}
{html_table}
{if},{elseif},{else}
{include_php}
{include}
{insert}
{ldelim},{rdelim}
{literal}
{mailto}
{math}
{nocache}
{php}
{section},{sectionelse}
{setfilter}
{strip}
{textformat}
{while}
Guides
Array indexes
Associative arrays
Attributes
BUGS
Basic Installation
Block Functions
Cache Groups
Cacheability of Plugins
Cacheability of Tags
Cacheability of Template Section
Cacheability of Variables
Charset Encoding
Comments
Compiler Functions
Custom Cache Implementation
Custom Template Resources
Embedding Vars in Double Quotes
Escaping Smarty Parsing
Extended Setup
Extends Template Resources
Functions
How Plugins Work
Inserts
Math
Modifiers
Multiple Caches Per Page
Naming Conventions
Objects
Output Filters
Prefilters/Postfilters
Requirements
Resources
Resources
Setting Up Caching
Smarty/PHP errors
SmartyBC class
Stream Template Resources
String Template Resources
Template Functions
Templates from $template_dir
Templates from a specific $template_dir
Templates from any directory
Variable scopes
Variables
Variables loaded from config files
What is Smarty?
Windows Filepaths
Writing Plugins
Methods
Smarty->addConfigDir()
Smarty->addPluginsDir()
Smarty->addTemplateDir()
Smarty->append()
Smarty->appendByRef()
Smarty->assign()
Smarty->assignByRef()
Smarty->clearAllAssign()
Smarty->clearAllCache()
Smarty->clearAssign()
Smarty->clearCache()
Smarty->clearCompiledTemplate()
Smarty->clearConfig()
Smarty->compileAllConfig()
Smarty->compileAllTemplates()
Smarty->configLoad()
Smarty->createData()
Smarty->createTemplate()
Smarty->disableSecurity()
Smarty->display()
Smarty->enableSecurity()
Smarty->fetch()
Smarty->getCacheDir()
Smarty->getCompileDir()
Smarty->getConfigDir()
Smarty->getConfigVars()
Smarty->getPluginsDir()
Smarty->getRegisteredObject()
Smarty->getTags()
Smarty->getTemplateDir()
Smarty->getTemplateVars()
Smarty->isCached()
Smarty->loadFilter()
Smarty->registerCacheResource()
Smarty->registerClass()
Smarty->registerDefaultPluginHandler()
Smarty->registerFilter()
Smarty->registerObject()
Smarty->registerPlugin()
Smarty->registerResource()
Smarty->setCacheDir()
Smarty->setCompileDir()
Smarty->setConfigDir()
Smarty->setPluginsDir()
Smarty->setTemplateDir()
Smarty->templateExists()
Smarty->testInstall()
Smarty->unregisterCacheResource()
Smarty->unregisterFilter()
Smarty->unregisterObject()
Smarty->unregisterPlugin
Smarty->unregisterResource()
Smarty::muteExpectedErrors()
Operators
capitalize
cat
count_characters
count_paragraphs
count_sentences
count_words
date_format
default
escape
from_charset
indent
lower
nl2br
regex_replace
replace
spacify
string_format
strip
strip_tags
to_charset
truncate
unescape
upper
wordwrap
Samples
$cache_id groups
$compile_id in a virtual host environment
$debugging_ctrl on localhost
$default_config_handler_func
$default_template_handler_func
/php/includes/guestbook/setup.php
/web/www.example.com/guestbook/htdocs/index.php
/web/www.example.com/guestbook/templates/index.tpl
A section's iteration property
A simple compiler function
A simple modifier plugin
A simple {foreach} loop
A simple {for} loop
Accessing arrays by index
Accessing associative array variables
Accessing object properties
Accessing {assign} variables from a PHP script
Add the library path to the php.ini file
An output filter plugin
Another Javascript example
Another {eval} example
Append {block} example
Appending an array
Appending the include path in a php script with ini_set()
Array of config #variables#
Assigment in the scope of calling template
Assigned variables
Assigning a template variable its default value
Assignment of an array element
Assignment of an multidimensional array element
Assignment with math
Associative array with the options attribute
Calling a recursive menu example
Clearing all caches for a particular $cache_id
Clearing the cache
Comments within a template
Converting form date elements back to a timestamp
Database example (eg ADODB or PEAR)
Database example (eg PEAR or ADODB):
Database example with a {sectionelse}
Database example with {foreachelse}
Default Plugin Handler Example
Demonstrates the an additional key variable
Disabling $compile_check
Displaying request variables
Dropdown with separate arrays for values and ouptut
Dropdown's with <optgroup>
Editing /web/www.example.com/docs/guestbook/index.php
Enable security with the default settings
Enabling caching
Example of config file syntax
Example of template the Obfuscating an email address
Example variables
Examples
Excution of {forelse}
Loading filter plugins
Looping a simple array with {section}
Looping an associative array with {section}
Modifier examples
More complex modifier plugin
Naming a {section}
Nested {section}'s
Nocache Variables
Other common errors
Other display() template resource examples
Other examples
PHP parsing errors
Passing a $cache_id to display()
Passing a cache_id to isCached()
Passing the title variable to the header template
Permissions and making directories writable
Prepend {block} example
Preventing a plugin's output from being cached
Preventing a template section from being cached
Preventing a template section from being cached
Preventing a whole passage of a template from being cached
Preventing tag output from being cached
Printing &nbsp; when a variable is empty
Recursive menu {function} example
Register class for use within a template
Register namespaced class for use within a template
Required Smarty library files
SMARTY_DIR
Set SMARTY_DIR constant manually
Setting $cache_lifetime per cache
Setting a different Charset Encoding
Setting security policy by extending the Smarty_Security class
Setting security policy by instance of the Smarty_Security class
Simple assignment
Simple {block} example
Simple {extends} example
Simple {include} example
Smarty errors
Smarty_CacheResource_Memcache
Smarty_CacheResource_Mysql
Specifying the $template_dir to use
Stream Variable
Stream from PHP
Stream from Template
Supply absolute path to library file
Syntax examples
Template inheritance by template resource extends:
Template inheritance example
Using SmartyBC
Using a registered or assigned object
Using a template outputfilter
Using a template postfilter
Using a template prefilter
Using custom resources
Using custom resources
Using date_format
Using fetch() to send an email
Using isCached()
Using template inheritance from the PHP script
Using templates from any directory
Using templates from encoded strings
Using templates from strings
Using templates from the $template_dir
Using templates from windows file paths
Using the auto-literal feature
Using the max attribute
Using {insert} to write a WML Content-Type header
Variable scope examples
Variables
Various {include} resource examples
What the file structure looks like
addConfigDir()
addPluginsDir()
addTemplateDir()
append
appendByRef
assign()
assignByRef()
block function
capitalize
cat
changing Smarty settings by template
changing delimiters example
clearAllAssign()
clearAllCache
clearAssign()
clearCache()
clearCompiledTemplate()
clearConfig()
combining modifiers
compileAllConfig()
compileAllTemplates()
componentized template
config variables
configLoad()
count_characters
count_paragraphs
count_sentences
count_words
createData()
createTemplate()
date_format
default
display()
escape
escape
fetch()
first property example
function attribute syntax
function plugin with output
function plugin without output
function syntax
function {config_load} with section
function {include_php}
function {insert}
getCacheDir()
getCompileDir()
getConfigDir()
getConfigVars()
getPluginsDir()
getRegisteredObject()
getTags()
getTemplateDir()
getTemplateVars
indent
index example
index, index_next and index_prev properties
insert plugin
isCached()
isCached() with multiple-cache template
iteration example: is div by
iteration example: is even/odd by
last property example
lower
math examples
nl2br
php code within {php} tags
postfilter plugin
prefilter plugin
regex_replace
register a function plugin
register block function plugin
register modifier plugin
register plugins by template
registerCacheResource()
registerResource()
replace
setCacheDir()
setCompileDir()
setConfigDir()
setPluginsDir()
setTemplateDir()
show property
show property example
spacify
static class access syntax
string_format
strip
strip_tags
templateExists()
testInstall()
total property example
total property example
truncate
unregister function plugin
unregisterCacheResource()
unregisterResource()
upper
wordwrap
{$smarty.block.child} example
{$smarty.block.parent} example
{append}
{assign}
{assign} a global variable
{assign} a variable to current scope tree
{assign} as a nocache variable
{assign} in the scope of calling template
{assign} with some maths
{break} example
{capture} into a template array variable
{capture} into a template variable
{capture} with the name attribute
{config_load}
{continue} example
{counter}
{cycle}
{eval}
{fetch} examples
{foreach} with nested item and key
{html_checkboxes}
{html_image} example
{html_radios} - Database example (eg PEAR or ADODB):
{html_radios} first example
{html_radios} second example
{html_select_date}
{html_select_date} second example
{html_select_time}
{html_table}
{if} statements
{if} with more examples
{include} and assign to variable
{include} passing variables
{include} using parent scope
{include} with disabled caching
{include} with forced caching
{include} with individual cache lifetime
{include} with relative paths
{ldelim}, {rdelim}
{literal} tags
{mailto} example lines followed by the result
{math}
{php} tags with global and assigning a variable
{section} demonstrating the loop variable
{section} index property
{section} property first and last
{section} property loop
{section} without an assigned array
{setfilter} tags
{strip} tags
{textformat}
{while} loop
Variables
Smarty->$allow_php_templates
Smarty->$auto_literal
Smarty->$autoload_filters
Smarty->$cache_dir
Smarty->$cache_id
Smarty->$cache_lifetime
Smarty->$cache_locking
Smarty->$cache_modified_check
Smarty->$caching
Smarty->$caching_type
Smarty->$compile_check
Smarty->$compile_dir
Smarty->$compile_id
Smarty->$compile_locking
Smarty->$compiler_class
Smarty->$config_booleanize
Smarty->$config_dir
Smarty->$config_overwrite
Smarty->$config_read_hidden
Smarty->$debug_tpl
Smarty->$debugging
Smarty->$debugging_ctrl
Smarty->$default_config_handler_func
Smarty->$default_config_type
Smarty->$default_modifiers
Smarty->$default_resource_type
Smarty->$default_template_handler_func
Smarty->$direct_access_security
Smarty->$error_reporting
Smarty->$escape_html
Smarty->$force_cache
Smarty->$force_compile
Smarty->$left_delimiter
Smarty->$locking_timeout
Smarty->$merge_compiled_includes
Smarty->$php_handling
Smarty->$plugins_dir
Smarty->$right_delimiter
Smarty->$smarty_debug_id
Smarty->$template_dir
Smarty->$trusted_dir
Smarty->$use_include_path
Smarty->$use_sub_dirs
{$smarty.block.child}
{$smarty.block.parent}
{$smarty.capture}
{$smarty.config}
{$smarty.const}
{$smarty.current_dir}
{$smarty.ldelim}, {$smarty.rdelim}
{$smarty.now}
{$smarty.section}
{$smarty.template_object}
{$smarty.template}
{$smarty.version}