From a033cd24d6be87f9bef2b891b661dc70e5343027 Mon Sep 17 00:00:00 2001 From: mohrt Date: Wed, 11 Apr 2001 20:12:12 +0000 Subject: [PATCH] update ChangeLog, update documentation --- NEWS | 4 ++ docs.sgml | 175 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 115 insertions(+), 64 deletions(-) diff --git a/NEWS b/NEWS index 3c8e52d2..ab7a1553 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ + - changed Smarty to compile templates at runtime, allowing for arbitrary + template resources. Also added fix for LOCK_EX under windows and changed + a couple file permissions for security. (Monte) - allow arbitrary date strings to date_format, html_select_date and html_select_time (Monte) + Version 1.3.2 ------------- - fixed a bug that caused some nested includes to loop infinitely. (Andrei) diff --git a/docs.sgml b/docs.sgml index 208fe95b..aeff35f3 100644 --- a/docs.sgml +++ b/docs.sgml @@ -137,8 +137,8 @@ caching, Smarty will store a copy of the generated template output, and use this until the copy expires, regenerating a new - one. The default cache expire time is one hour, and can be - configured from the class. The exception to the rule is the insert tag. Anything generated by the insert tag is not cached, but run dynamically on every invocation, even within cached content. @@ -242,8 +242,11 @@ chmod 700 cache $template_dir - This is the name of the directory where template files are located. - By default this is "./templates". + This is the name of the default template directory. If you do + not supply a resource type when including files, they will be + found here. By default this is "./templates", meaning that it + will look for the templates directory in the same directory as + the executing php script. TECHNICAL NOTE: It is not mandatory to put this directory under @@ -253,9 +256,11 @@ chmod 700 cache $compile_dir - This is the name of the directory where compiled templates are - located. By default this is "./templates_c". This was - added to Smarty version 1.2.1. + This is the name of the directory where compiled templates are + located. By default this is "./templates_c", meaning that it + will look for the compile directory in the same directory as + the executing php script. This was added to Smarty version + 1.2.1. TECHNICAL NOTE: This setting must be either a relative or @@ -269,8 +274,10 @@ chmod 700 cache $config_dir - This is the directory used to store config files used in the templates. - Default is "./configs". + This is the directory used to store config files used in the + templates. Default is "./configs", meaning that it will look + for the configs directory in the same directory as the + executing php script. TECHNICAL NOTE: It is not mandatory to put this directory under @@ -290,24 +297,23 @@ chmod 700 cache $compile_check - Upon each invocation of the PHP application, Smarty recursively - traverses the template directory and its subdirectories and - searches for templates that have changed (later time stamp) - since the last time they were compiled. For each one that has - changed, it recompiles that template. By default this variable - is set to true. Once an application is put into production and - it is initially compiled, the compile_check step is no longer - needed. Be sure to set $compile_check to "false" to improve - performance! Note that if you change this to "false" and a - template file is changed, you will *not* see the change since - the template will not get recompiled. See $force_compile + Upon each invocation of the PHP application, Smarty tests to + see if the current template has changed (later time stamp) + since the last time it was compiled. If it has changed, it + recompiles that template. By default this variable is set to + true. Once an application is put into production and all + templates are initially compiled, the compile_check step is no + longer needed. Be sure to set $compile_check to "false" to + improve performance! Note that if you change this to "false" + and a template file is changed, you will *not* see the change + since the template will not get recompiled. See $force_compile $force_compile - This forces Smarty to compile all templates on every + This forces Smarty to (re)compile each template on every invocation. This setting overrides $compile_check. By default this is disabled. This is handy for development and debugging. It should never be used in a production environment. @@ -328,9 +334,10 @@ chmod 700 cache $cache_dir - This is the name of the directory where template caches are - located. By default this is "./cache". This was - added to Smarty version 1.3.0. + This is the name of the directory where template caches are + stored. By default this is "./cache", meaning that it will + look for the cache directory in the same directory as the + executing php script. This was added to Smarty version 1.3.0. TECHNICAL NOTE: This setting must be either a relative or @@ -352,25 +359,6 @@ chmod 700 cache added to Smarty 1.3.0. - - $tpl_file_ext - - This is the extention used for template files. By default this - is ".tpl". All other files in the template directory are - ignored. - - - - $allow_php - - Whether or not to allow PHP code in the templates. If set to - false, PHP code is escaped and not interpreted. Embedding PHP - code into templates is highly discouraged. Use custom functions or modifiers instead. Default - is "false". - - $php_handling @@ -574,8 +562,8 @@ $smarty->clear_all_assign(); Use this to dynamically register functions with Smarty. Pass in - the Smarty function name, followed by the actual function name - that it is mapped to. + the template function name, followed by the actual PHP function + name that it will map to. register_function @@ -683,8 +671,8 @@ $smarty->unregister_modifier("fetch"); Use this to dynamically register modifiers with Smarty. Pass in - the Smarty modifier name, followed by the actual function name - that it is mapped to. + the template modifier name, followed by the actual PHP function name + that it will map to. register_modifier @@ -709,7 +697,7 @@ $smarty->register_modifier("sslash","stripslashes"); Use this to dynamically unregister modifiers with Smarty. Pass in - the Smarty modifier name. + the template modifier name. unregister_modifier @@ -804,11 +792,11 @@ var_dump($tpl_vars); - This displays the template. Supply a path relative to the - template directory. - As an optional second parameter, you can pass a cache id. - See the caching section for - more information. + This displays the template. Supply a valid template resource + type and path. As an optional second parameter, you can pass a + cache id. See the caching + section for more information. display @@ -852,8 +840,11 @@ $smarty->display("index.tpl"); This returns the template output instead of displaying it. - Supply a path relative to the template directory + Supply a valid template resource + type and path. As an optional second parameter, you can pass a + cache id. See the caching + section for more information. fetch @@ -892,6 +883,59 @@ echo $output; + + Smarty Template Resources + + Your templates may come from a variety of sources. When you display or + fetch a template, or when you include a template from within another + template, you supply a resource type, followed by the appropriate path + and template name. Template resources were added to Smarty 1.4.0. + + + Templates from $template_dir + + Templates from the $template_dir do not require a template resource. + Just supply the path to the template you want to use relative to the + $template_dir root directory. + + + +using templates from $template_dir + + +// from PHP script +$smarty->display("index.tpl"); +$smarty->display("admin/menu.tpl"); + +{* from within Smarty template *} +{include file="index.tpl"} + + + + + + Templates from any directory + + Templates outside of the $template_dir require the file: template + resource type, followed by the absolute path and name of the + template. + + + +using templates from any directory + + +// from PHP script +$smarty->display("file:/export/templates/index.tpl"); +$smarty->display("file:/path/to/my/templates/menu.tpl"); + +{* from within Smarty template *} +{include file="file:/usr/local/share/templates/navigation.tpl"} + + + + + Smarty Templates @@ -2989,9 +3033,11 @@ Dealers Will Hear Car Talk at Noon. - This formats a date and time into the given strftime() format. All - dates should be passed to Smarty as a timestamp so that the - template designer has full control of how this date is formatted. + This formats a date and time into the given strftime() format. + Dates can be passed to Smarty as unix timestamps, mysql timestamps + or any string made up of month day year (parsable by strtotime). + Designers can then use date_format to have complete control of the + formatting of the date. date_format @@ -3090,10 +3136,10 @@ is the first week that has at least 4 days in the current year, and with Monday %% - a literal `%' character -PROGRAMMERS NOTE: date_format is a wrapper to PHP's strftime() function. You -may have more or less conversion specifiers available depending on your -system's strftime() function where PHP was compiled. Check your system's manpage -for a full list of valid specifiers. +PROGRAMMERS NOTE: date_format is essentially a wrapper to PHP's strftime() +function. You may have more or less conversion specifiers available depending +on your system's strftime() function where PHP was compiled. Check your +system's manpage for a full list of valid specifiers. @@ -3616,7 +3662,8 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75 Dates - As a rule of thumb, always pass dates to Smarty as timestamps. + Dates can be passed to Smarty as unix timestamps, mysql timestamps, + or a parsable string made of month day and year (parsable by strtotime()) This allows template designers to use date_format for full control over date formatting, and also makes it easy to compare dates if necessary.