diff --git a/FAQ b/FAQ index 7c09be26..a1c9664e 100644 --- a/FAQ +++ b/FAQ @@ -66,6 +66,7 @@ Q: Do you have a mailing list? A: Yes. Subscribe by sending an e-mail to subscribe-smarty@lists.ispi.net. This is also archived at http://marc.theaimsgroup.com/ under www/smarty + TROUBLESHOOTING --------------- @@ -126,5 +127,12 @@ A: This was fixed in 1.3.2 (new global attribute) Q: How can I tell what compiled template file corresponds to to which source file? (Smarty 1.4.0 and later have encoded compiled filenames) A: Compiled template files have headers that tell which source file was used to - compile it. cd into the compile_dir and type "head -2 *" to see the first - two lines of each compiled file. + compile it. Grep for the pathname, or use "head -2 *" to see the first two + lines of each compiled file. + +Q: My ISP did not setup the PEAR repository, nor will they set it up. How do I + make Smarty run without it? +A: The easiest thing to do is grab all of PEAR and install it locally for your + own use. There's nothing that says PEAR must be installed in its default + directory. There won't be a version of Smarty that runs without PEAR, as it + quite dependant on it, especially with database support. diff --git a/NEWS b/NEWS index 3ee6173b..91d7e9cc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - added $check_cached_insert_tags to speed up cached pages if + {insert ...} is not used (Monte) - added $compiler_class variable to allow specifying a different compiler class. (Andrei) - changed Smarty to compile templates at runtime, allowing for arbitrary diff --git a/RELEASE_NOTES b/RELEASE_NOTES index f67e0703..33dfea37 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -5,13 +5,13 @@ The most significant change to Smarty 1.4.0 is the compilation process. Instead of compiling all the templates up front, it now compiles them at runtime. This has several advantages. First off, there is no longer a need to have a single template directory. You can now have arbitrary template sources, such as -multiple directories or even database calls. This also speeds the performance of -Smarty when $compile_check is enabled, since it is only checking the template -that is being executed instead of everything found in the template directory. -The $tpl_file_ext variable was removed since this is no longer needed, so -templates can be named anything you like with any extension. Smarty makes use of -the PEAR database abstraction class for obtaining templates from databases. Now -aren't you glad we require PEAR :-) +multiple directories or even database calls. This also speeds the performance +of Smarty when $compile_check is enabled, since it is only checking the +template that is being executed instead of everything found in the template +directory. The $tpl_file_ext is no longer needed, but kept for backward +compatability. Templates can now be named anything you like with any extension. +Smarty makes use of the PEAR database abstraction class for obtaining templates +from databases. We also added a workaround for LOCK_EX on Windows systems, and changed a couple of file permissions for better security on public servers. Thanks goes to @@ -21,7 +21,7 @@ date_format, html_select_date and html_select_time used to require a unix timestamp as the format of the date passed into the template. Smarty is now a bit smarter at this. It will take a unix timestamp, a mysql timestamp, or any date string that is parsable by strtotime, such as 10/01/2001 or 2001-10-01, -etc. Just give it a try and see what works. +etc. Just give some formats a try and see what works. When upgrading to 1.4.0, you will want to first clear out all your files in the $compile_dir, since it now uses a new format. Since templates can come from any @@ -32,4 +32,35 @@ false and the compiled template does not yet exist, it will compile it regardless of this setting. Once it is compiled though, it will not check to see if recompilation is necessary. --Monte +1.3.2 +----- + +Smarty now has (an optional) header prepended to the output of the Smarty +templates. This displays the Smarty version and the date/time when the page was +generated. This is useful for debugging your cache routines, and purely +informational so there is evidence that the page was generated by Smarty. Set +$show_info_header to false to disable it. + +{config_load ...} performance was tuned by placing the loaded variables into a +global array, so basically a config file is read from the file system and +placed into a php array structure only once, no matter how many times it is +called in any of the templates. The scope of the loaded variables has changed a +bit as well. Variables loaded by config_load used to be treated as global +variables, meaning that parent templates (templates that included the current +template) could see them. Now the default behavior is such that loaded +variables are only visible by the current template and child templates (all +templates included after the {config_load ...} is called.) To mimic the +original behavior, provide the attribute "global=yes" like so: {config_load +file="mystuff.conf" global=yes}. Now when you load in mystuff.conf, the +variables will be visible to parent templates (merged with any existing config +variables.) + +A formatting attribute was added to the {math ...} function, adding the ability +to control the format of the output. Use the same formatting syntax as the PHP +function sprintf(). + +{html_select_time ...} was added, a custom function that works much like +{html_select_date ...} except it displays time elements instead of dates. + +A few custom modifiers were added: count_characters, count_words, +count_sentences, count_paragraphs. All pretty self-explanatory. diff --git a/Smarty.class.php b/Smarty.class.php index 2bb068b5..a0e59934 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -78,6 +78,12 @@ class Smarty var $cache_dir = './cache'; // name of directory for template cache var $cache_lifetime = 3600; // number of seconds cached content will persist. // 0 = never expires. default is one hour (3600) + var $check_cached_insert_tags = true; // if you have caching turned on and you + // don't use {insert} tags anywhere + // in your templates, set this to false. + // this will tell Smarty not to look for + // insert tags and speed up cached page + // fetches. var $tpl_file_ext = '.tpl'; // template file extention @@ -361,7 +367,9 @@ class Smarty ($this->cache_lifetime == 0 || (time() - filemtime($cache_file) <= $this->cache_lifetime))) { $results = $this->_read_file($cache_file); - $results = $this->_process_cached_inserts($results); + if($this->check_cached_insert_tags) { + $results = $this->_process_cached_inserts($results); + } if ($display) { echo $results; return; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 2bb068b5..a0e59934 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -78,6 +78,12 @@ class Smarty var $cache_dir = './cache'; // name of directory for template cache var $cache_lifetime = 3600; // number of seconds cached content will persist. // 0 = never expires. default is one hour (3600) + var $check_cached_insert_tags = true; // if you have caching turned on and you + // don't use {insert} tags anywhere + // in your templates, set this to false. + // this will tell Smarty not to look for + // insert tags and speed up cached page + // fetches. var $tpl_file_ext = '.tpl'; // template file extention @@ -361,7 +367,9 @@ class Smarty ($this->cache_lifetime == 0 || (time() - filemtime($cache_file) <= $this->cache_lifetime))) { $results = $this->_read_file($cache_file); - $results = $this->_process_cached_inserts($results); + if($this->check_cached_insert_tags) { + $results = $this->_process_cached_inserts($results); + } if ($display) { echo $results; return;