Smarty
public class Smarty
Field Summary | |
---|---|
array array of filter names | This indicates which filters are automatically loaded into Smarty. |
string | The name of the directory for cache files. |
null|string function name | The function used for cache file handling. |
integer | This is the number of seconds cached content will persist. |
boolean | Only used when $caching is enabled. |
integer | This enables template caching. |
boolean | This tells Smarty whether to check for recompiling or not. |
string | The directory where compiled templates are located. |
string | Set this if you want different sets of compiled files for the same templates. |
string | The class used for compiling templates. |
string | The file that contains the compiler class. |
mixed | This tells whether or not to automatically booleanize config file variables. |
string | The class used to load config vars. |
string | The directory where config files are located. |
mixed | This tells whether or not automatically fix newlines in config files. |
boolean | This tells if config file vars of the same name overwrite each other or not. |
mixed | This tells whether hidden sections [.foobar] are readable from the tempalates or not. |
string | This is the path to the debug console template. |
boolean | If debugging is enabled, a debug console window will display when the page loads (make sure your browser allows unrequested popup windows) |
string | This determines if debugging is enable-able from the browser. |
array | This is a list of the modifiers to apply to all template variables. |
array | This is the resource type to be used when not specified at the beginning of the resource path. |
string function name | $default_template_handler_func If a template cannot be found, this PHP function will be executed. |
boolean | When set, smarty does uses this value as error_reporting-level. |
boolean | This forces templates to compile every time. |
string | The left delimiter used for the template tags. |
integer | This determines how Smarty handles " |
array | An array of directories searched for plugins. |
boolean | Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) are uses as request-vars or $_*[]-vars. |
string | The order in which request variables are registered, similar to variables_order in php.ini E = Environment, G = GET, P = POST, C = Cookies, S = Server |
string | The right delimiter used for the template tags. |
array | This is the list of template directories that are considered secure. |
boolean | This enables template security. |
array | These are the security settings for Smarty. |
string | The name of the directory where templates are located. |
array | This is an array of directories where trusted php scripts reside. |
boolean / | This tells Smarty whether or not to use sub dirs in the cache/ and templates_c/ directories. |
Constructor Summary | |
---|---|
Smarty() The class constructor. |
Method Summary | |
---|---|
void | append(array|string tpl_var, mixed value, mixed merge) appends values to template variables |
void | append_by_ref(string tpl_var, mixed value, mixed merge) appends values to template variables by reference |
void | assign(array|string tpl_var, mixed value) assigns values to template variables |
void | assign_by_ref(string tpl_var, mixed value) assigns values to template variables by reference |
void | clear all the assigned template variables. |
boolean | clear_all_cache(string exp_time) clear the entire contents of cache (all templates) |
void | clear_assign(string tpl_var) clear the given assigned template variable. |
boolean | clear_cache(string tpl_file, string cache_id, string compile_id, string exp_time) clear cached content for the given template and cache id |
boolean | clear_compiled_tpl(string tpl_file, string compile_id, string exp_time) clears compiled version of specified template resource, or all compiled template files if one is not specified. |
void | clear_config(string var) clear configuration values |
static void | config_load(string file, string section, string scope) load configuration values |
void | display(string resource_name, string cache_id, string compile_id) executes & displays the template results |
void | fetch(string resource_name, string cache_id, string compile_id, boolean display) executes & returns or displays the template results |
array | get_config_vars(string name, string type) Returns an array containing config variables |
object | get_registered_object(string name) return a reference to a registered object |
array | get_template_vars(string name, string type) Returns an array containing template variables |
string|false | is_cached(string tpl_file, string cache_id, string compile_id) test to see if valid cache exists for this template |
void | load_filter(string type, string name) load a filter of specified type and name |
void | register_block(string block, string block_impl, mixed cacheable, mixed cache_attrs) Registers block function to be used in templates |
void | register_compiler_function(string function, string function_impl, mixed cacheable) Registers compiler function |
void | register_function(string function, string function_impl, mixed cacheable, mixed cache_attrs) Registers custom function to be used in templates |
void | register_modifier(string modifier, string modifier_impl) Registers modifier to be used in templates |
void | register_object(string object, mixed object_impl, null|array allowed, mixed block_methods, object &$object_impl, boolean smarty_args, null|array block_functs) Registers object to be used in templates |
void | register_outputfilter(callback function) Registers an output filter function to apply to a template output |
void | register_postfilter(callback function) Registers a postfilter function to apply to a compiled template after compilation |
void | register_prefilter(callback function) Registers a prefilter function to apply to a template before compiling |
void | register_resource(string type, array functions) Registers a resource to fetch a template |
boolean | template_exists(string tpl_file) Checks whether requested template exists. |
void | trigger_error(string error_msg, integer error_type) trigger Smarty error |
void | unregister_block(string block) Unregisters block function |
void | unregister_compiler_function(string function) Unregisters compiler function |
void | unregister_function(string function) Unregisters custom function |
void | unregister_modifier(string modifier) Unregisters modifier |
void | unregister_object(string object) Unregisters object |
void | unregister_outputfilter(callback function) Unregisters an outputfilter function |
void | unregister_postfilter(callback function) Unregisters a postfilter function |
void | unregister_prefilter(callback function) Unregisters a prefilter function |
void | unregister_resource(string type) Unregisters a resource |
public array array of filter names $autoload_filters = array()
This indicates which filters are automatically loaded into Smarty.
public string $cache_dir = 'cache'
The name of the directory for cache files.
public null|string function name $cache_handler_func = null
The function used for cache file handling. If not set, built-in caching is used.
public integer $cache_lifetime = 3600
This is the number of seconds cached content will persist.
public boolean $cache_modified_check = false
Only used when $caching is enabled. If true, then If-Modified-Since headers are respected with cached content, and appropriate HTTP headers are sent. This way repeated hits to a cached page do not send the entire page to the client every time.
public integer $caching
This enables template caching.
public boolean $compile_check = true
This tells Smarty whether to check for recompiling or not. Recompiling does not need to happen unless a template or config file is changed. Typically you enable this during development, and disable for production.
public string $compile_dir = 'templates_c'
The directory where compiled templates are located.
public string $compile_id = null
Set this if you want different sets of compiled files for the same templates. This is useful for things like different languages. Instead of creating separate sets of templates per language, you set different compile_ids like 'en' and 'de'.
public string $compiler_class = 'Smarty_Compiler'
The class used for compiling templates.
public string $compiler_file = 'Smarty_Compiler.class.php'
The file that contains the compiler class. This can a full pathname, or relative to the php_include path.
public mixed $config_booleanize = true
This tells whether or not to automatically booleanize config file variables. If enabled, then the strings "on", "true", and "yes" are treated as boolean true, and "off", "false" and "no" are treated as boolean false.
public string $config_class = 'Config_File'
The class used to load config vars.
public string $config_dir = 'configs'
The directory where config files are located.
public mixed $config_fix_newlines = true
This tells whether or not automatically fix newlines in config files. It basically converts \r (mac) or \r\n (dos) to \n
public boolean $config_overwrite = true
This tells if config file vars of the same name overwrite each other or not. if disabled, same name variables are accumulated in an array.
public mixed $config_read_hidden = false
This tells whether hidden sections [.foobar] are readable from the tempalates or not. Normally you would never allow this since that is the point behind hidden sections: the application can access them, but the templates cannot.
public string $debug_tpl = ''
This is the path to the debug console template. If not set, the default one will be used.
public boolean $debugging = false
If debugging is enabled, a debug console window will display when the page loads (make sure your browser allows unrequested popup windows)
public string $debugging_ctrl = 'NONE'
This determines if debugging is enable-able from the browser.
public array $default_modifiers = array()
This is a list of the modifiers to apply to all template variables.
Put each modifier in a separate array element in the order you want
them applied. example: array('escape:"htmlall"');
public array $default_resource_type = 'file'
This is the resource type to be used when not specified at the beginning of the resource path. examples: $smarty->display('file:index.tpl'); $smarty->display('db:index.tpl'); $smarty->display('index.tpl'); // will use default resource type {include file="file:index.tpl"} {include file="db:index.tpl"} {include file="index.tpl"} {* will use default resource type *}
public string function name $default_template_handler_func = ''
If a template cannot be found, this PHP function will be executed. Useful for creating templates on-the-fly or other special action.
public boolean $error_reporting = null
When set, smarty does uses this value as error_reporting-level.
public boolean $force_compile = false
This forces templates to compile every time. Useful for development or debugging.
public string $left_delimiter = '{'
The left delimiter used for the template tags.
public integer $php_handling = SMARTY_PHP_PASSTHRU
This determines how Smarty handles "" tags in templates. possible values:
public array $plugins_dir = array('plugins')
An array of directories searched for plugins.
public boolean $request_use_auto_globals = true
Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) are uses as request-vars or $_*[]-vars. note: if request_use_auto_globals is true, then $request_vars_order has no effect, but the php-ini-value "gpc_order"
public string $request_vars_order = 'EGPCS'
The order in which request variables are registered, similar to variables_order in php.ini E = Environment, G = GET, P = POST, C = Cookies, S = Server
public string $right_delimiter = '}'
The right delimiter used for the template tags.
public array $secure_dir = array()
This is the list of template directories that are considered secure. This
is used only if $security
is enabled. One directory per array
element. $template_dir
is in this list implicitly.
public boolean $security = false
This enables template security. When enabled, many things are restricted in the templates that normally would go unchecked. This is useful when untrusted parties are editing templates and you want a reasonable level of security. (no direct execution of PHP in templates for example)
public array $security_settings = array(...)
These are the security settings for Smarty. They are used only when
$security
is enabled.
public string $template_dir = 'templates'
The name of the directory where templates are located.
public array $trusted_dir = array()
This is an array of directories where trusted php scripts reside.
$security
is disabled during their inclusion/execution.
public boolean / $use_sub_dirs = false
This tells Smarty whether or not to use sub dirs in the cache/ and templates_c/ directories. sub directories better organized, but may not work well with PHP safe mode enabled.
public Smarty()
The class constructor.
public void append(array|string tpl_var, mixed value, mixed merge)
appends values to template variables
public void append_by_ref(string tpl_var, mixed value, mixed merge)
appends values to template variables by reference
public void assign(array|string tpl_var, mixed value)
assigns values to template variables
public void assign_by_ref(string tpl_var, mixed value)
assigns values to template variables by reference
public void clear_all_assign()
clear all the assigned template variables.
public boolean clear_all_cache(string exp_time)
clear the entire contents of cache (all templates)
public void clear_assign(string tpl_var)
clear the given assigned template variable.
public boolean clear_cache(string tpl_file, string cache_id, string compile_id, string exp_time)
clear cached content for the given template and cache id
public boolean clear_compiled_tpl(string tpl_file, string compile_id, string exp_time)
clears compiled version of specified template resource, or all compiled template files if one is not specified. This function is for advanced use only, not normally needed.
public void clear_config(string var)
clear configuration values
public static void config_load(string file, string section, string scope)
load configuration values
public void display(string resource_name, string cache_id, string compile_id)
executes & displays the template results
public void fetch(string resource_name, string cache_id, string compile_id, boolean display)
executes & returns or displays the template results
public array get_config_vars(string name, string type)
Returns an array containing config variables
public object get_registered_object(string name)
return a reference to a registered object
public array get_template_vars(string name, string type)
Returns an array containing template variables
public string|false is_cached(string tpl_file, string cache_id, string compile_id)
test to see if valid cache exists for this template
public void load_filter(string type, string name)
load a filter of specified type and name
public void register_block(string block, string block_impl, mixed cacheable, mixed cache_attrs)
Registers block function to be used in templates
public void register_compiler_function(string function, string function_impl, mixed cacheable)
Registers compiler function
public void register_function(string function, string function_impl, mixed cacheable, mixed cache_attrs)
Registers custom function to be used in templates
public void register_modifier(string modifier, string modifier_impl)
Registers modifier to be used in templates
public void register_object(string object, mixed object_impl, null|array allowed, mixed block_methods, object &$object_impl, boolean smarty_args, null|array block_functs)
Registers object to be used in templates
public void register_outputfilter(callback function)
Registers an output filter function to apply to a template output
public void register_postfilter(callback function)
Registers a postfilter function to apply to a compiled template after compilation
public void register_prefilter(callback function)
Registers a prefilter function to apply to a template before compiling
public void register_resource(string type, array functions)
Registers a resource to fetch a template
public boolean template_exists(string tpl_file)
Checks whether requested template exists.
public void trigger_error(string error_msg, integer error_type)
trigger Smarty error
public void unregister_block(string block)
Unregisters block function
public void unregister_compiler_function(string function)
Unregisters compiler function
public void unregister_function(string function)
Unregisters custom function
public void unregister_modifier(string modifier)
Unregisters modifier
public void unregister_object(string object)
Unregisters object
public void unregister_outputfilter(callback function)
Unregisters an outputfilter function
public void unregister_postfilter(callback function)
Unregisters a postfilter function
public void unregister_prefilter(callback function)
Unregisters a prefilter function
public void unregister_resource(string type)
Unregisters a resource